Skip to content

Commit d63a841

Browse files
committed
fix: fixed issues with cbl-js-swift and collections, prepared for sql parameters
1 parent f45fea3 commit d63a841

File tree

5 files changed

+100
-33
lines changed

5 files changed

+100
-33
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import { Database } from 'cbl-reactnative';
3+
import execute from '@/service/query/execute';
4+
import explain from '@/service/query/explain';
5+
import CBLDatabaseQueryActionContainer from '@/components/CBLDatabaseQueryActionContainer';
6+
7+
export default function QueryParametersScreen() {
8+
function reset() {}
9+
10+
async function runQuery(
11+
database: Database,
12+
sqlQuery: string,
13+
isExplain: boolean
14+
): Promise<string[]> {
15+
try {
16+
const date = new Date().toISOString();
17+
const dict: string[] = [];
18+
if (isExplain) {
19+
const result = await explain(sqlQuery, null, database);
20+
dict.push(`${date}::Explain: <<${result}>>`);
21+
return dict;
22+
} else {
23+
const results = await execute(sqlQuery, null, database);
24+
if (results.length === 0) {
25+
dict.push(`${date}::INFO: No results`);
26+
} else {
27+
for (const result of results) {
28+
dict.push(`${date}::Data: <<${JSON.stringify(result)}>>`);
29+
}
30+
}
31+
return dict;
32+
}
33+
} catch (error) {
34+
// @ts-ignore
35+
return [error.message];
36+
}
37+
}
38+
function updatePressed(
39+
database: Database,
40+
sqlQuery: string
41+
): Promise<string[]> {
42+
return runQuery(database, sqlQuery, false);
43+
}
44+
45+
function explainPressed(
46+
database: Database,
47+
sqlQuery: string
48+
): Promise<string[]> {
49+
return runQuery(database, sqlQuery, true);
50+
}
51+
52+
return (
53+
<CBLDatabaseQueryActionContainer
54+
screenTitle={'Query Parameters'}
55+
handleUpdatePressed={updatePressed}
56+
handleExplainedPressed={explainPressed}
57+
handleResetPressed={reset}
58+
/>
59+
);
60+
}

expo-example/app/query/sqlPlusPlus.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ export default function QuerySqlPlusPlusScreen() {
1717
const dict: string[] = [];
1818
if (isExplain) {
1919
const result = await explain(sqlQuery, null, database);
20-
dict.push(`${date}::<<${result}>>`);
20+
dict.push(`${date}::Explain: <<${result}>>`);
2121
return dict;
2222
} else {
2323
const results = await execute(sqlQuery, null, database);
24-
for (const result of results) {
25-
dict.push(`${date}::<<${JSON.stringify(result)}>>`);
24+
if (results.length === 0) {
25+
dict.push(`${date}::INFO: No results`);
26+
} else {
27+
for (const result of results) {
28+
dict.push(`${date}::Data: <<${JSON.stringify(result)}>>`);
29+
}
2630
}
2731
return dict;
2832
}

expo-example/components/ResultsListView.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import HeaderView from '@/components/HeaderView';
22
import React from 'react';
3-
import { ScrollView } from 'react-native';
3+
import { ScrollView, View } from 'react-native';
44
import { Text } from '@/components/Themed';
55
import { ResultsListViewProps } from '@/types/resultsListViewProps.type';
66
import { Divider } from '@gluestack-ui/themed';
@@ -10,15 +10,18 @@ export default function ResultListView({ messages }: ResultsListViewProps) {
1010
return (
1111
<>
1212
<HeaderView name={'Results'} iconName={'information'} />
13-
<ScrollView style={{ marginLeft: 16, marginTop: 2 }}>
13+
<ScrollView>
1414
{messages?.map((message, index) => (
15-
<>
15+
<View
16+
style={{ marginLeft: 16, marginTop: 12 }}
17+
key={`view-${index}-${date}`}
18+
>
1619
<Text key={`message-${index}-${date}`}>{message}</Text>
1720
<Divider
1821
key={`divider-${index}-${date}`}
19-
style={{ marginTop: 16, marginBottom: 16, marginLeft: 2 }}
22+
style={{ marginTop: 14, marginBottom: 4, marginLeft: 2 }}
2023
/>
21-
</>
24+
</View>
2225
))}
2326
</ScrollView>
2427
</>

expo-example/ios/expoexample.xcodeproj/project.pbxproj

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
1111
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1212
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
13+
2A822BC3790FC960F3EDCD8E /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = EC3C7BD8CC67845DE0F37555 /* PrivacyInfo.xcprivacy */; };
1314
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */; };
14-
963CF31A941C4CD3A9357BE8 /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF70CC4CA1714790B122C123 /* noop-file.swift */; };
15+
71C7831EDF474CEBAD2BE216 /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2701DA36394F66B41E0F42 /* noop-file.swift */; };
1516
96905EF65AED1B983A6B3ABC /* libPods-expoexample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58EEBF8E8E6FB1BC6CAF49B5 /* libPods-expoexample.a */; };
1617
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
1718
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
18-
F7C0828CFD6C492440B9DEBB /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4E9636163AEDF6B0BCEB0A9F /* PrivacyInfo.xcprivacy */; };
1919
/* End PBXBuildFile section */
2020

2121
/* Begin PBXFileReference section */
@@ -25,14 +25,14 @@
2525
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = expoexample/Images.xcassets; sourceTree = "<group>"; };
2626
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = expoexample/Info.plist; sourceTree = "<group>"; };
2727
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = expoexample/main.m; sourceTree = "<group>"; };
28-
4E9636163AEDF6B0BCEB0A9F /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = expoexample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
29-
52C3A2694BF7497D9B3CD3F5 /* expoexample-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "expoexample-Bridging-Header.h"; path = "expoexample/expoexample-Bridging-Header.h"; sourceTree = "<group>"; };
28+
2C2701DA36394F66B41E0F42 /* noop-file.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = "noop-file.swift"; path = "expoexample/noop-file.swift"; sourceTree = "<group>"; };
3029
58EEBF8E8E6FB1BC6CAF49B5 /* libPods-expoexample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-expoexample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
3130
6C2E3173556A471DD304B334 /* Pods-expoexample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-expoexample.debug.xcconfig"; path = "Target Support Files/Pods-expoexample/Pods-expoexample.debug.xcconfig"; sourceTree = "<group>"; };
3231
7A4D352CD337FB3A3BF06240 /* Pods-expoexample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-expoexample.release.xcconfig"; path = "Target Support Files/Pods-expoexample/Pods-expoexample.release.xcconfig"; sourceTree = "<group>"; };
3332
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SplashScreen.storyboard; path = expoexample/SplashScreen.storyboard; sourceTree = "<group>"; };
3433
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
35-
CF70CC4CA1714790B122C123 /* noop-file.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = "noop-file.swift"; path = "expoexample/noop-file.swift"; sourceTree = "<group>"; };
34+
E1CFE4310B674E26AEE607EA /* expoexample-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "expoexample-Bridging-Header.h"; path = "expoexample/expoexample-Bridging-Header.h"; sourceTree = "<group>"; };
35+
EC3C7BD8CC67845DE0F37555 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = expoexample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3636
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
3737
FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-expoexample/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
3838
/* End PBXFileReference section */
@@ -59,9 +59,9 @@
5959
13B07FB61A68108700A75B9A /* Info.plist */,
6060
13B07FB71A68108700A75B9A /* main.m */,
6161
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */,
62-
CF70CC4CA1714790B122C123 /* noop-file.swift */,
63-
52C3A2694BF7497D9B3CD3F5 /* expoexample-Bridging-Header.h */,
64-
4E9636163AEDF6B0BCEB0A9F /* PrivacyInfo.xcprivacy */,
62+
2C2701DA36394F66B41E0F42 /* noop-file.swift */,
63+
E1CFE4310B674E26AEE607EA /* expoexample-Bridging-Header.h */,
64+
EC3C7BD8CC67845DE0F37555 /* PrivacyInfo.xcprivacy */,
6565
);
6666
name = expoexample;
6767
sourceTree = "<group>";
@@ -147,13 +147,13 @@
147147
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "expoexample" */;
148148
buildPhases = (
149149
08A4A3CD28434E44B6B9DE2E /* [CP] Check Pods Manifest.lock */,
150-
15F278EF833B933853C8ECB8 /* [Expo] Configure project */,
150+
03F222F555AA5FCA86EF177B /* [Expo] Configure project */,
151151
13B07F871A680F5B00A75B9A /* Sources */,
152152
13B07F8C1A680F5B00A75B9A /* Frameworks */,
153153
13B07F8E1A680F5B00A75B9A /* Resources */,
154154
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
155155
800E24972A6A228C8D4807E9 /* [CP] Copy Pods Resources */,
156-
EC3CC923263A7AEA31493FDC /* [CP] Embed Pods Frameworks */,
156+
E7AB3CAEC83848EFF07424DB /* [CP] Embed Pods Frameworks */,
157157
);
158158
buildRules = (
159159
);
@@ -203,7 +203,7 @@
203203
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */,
204204
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
205205
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */,
206-
F7C0828CFD6C492440B9DEBB /* PrivacyInfo.xcprivacy in Resources */,
206+
2A822BC3790FC960F3EDCD8E /* PrivacyInfo.xcprivacy in Resources */,
207207
);
208208
runOnlyForDeploymentPostprocessing = 0;
209209
};
@@ -225,46 +225,46 @@
225225
shellPath = /bin/sh;
226226
shellScript = "if [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\n source \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n# The project root by default is one level up from the ios directory\nexport PROJECT_ROOT=\"$PROJECT_DIR\"/..\n\nif [[ \"$CONFIGURATION\" = *Debug* ]]; then\n export SKIP_BUNDLING=1\nfi\nif [[ -z \"$ENTRY_FILE\" ]]; then\n # Set the entry JS file using the bundler's entry resolution.\n export ENTRY_FILE=\"$(\"$NODE_BINARY\" -e \"require('expo/scripts/resolveAppEntry')\" \"$PROJECT_ROOT\" ios absolute | tail -n 1)\"\nfi\n\nif [[ -z \"$CLI_PATH\" ]]; then\n # Use Expo CLI\n export CLI_PATH=\"$(\"$NODE_BINARY\" --print \"require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })\")\"\nfi\nif [[ -z \"$BUNDLE_COMMAND\" ]]; then\n # Default Expo CLI command for bundling\n export BUNDLE_COMMAND=\"export:embed\"\nfi\n\n# Source .xcode.env.updates if it exists to allow\n# SKIP_BUNDLING to be unset if needed\nif [[ -f \"$PODS_ROOT/../.xcode.env.updates\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.updates\"\nfi\n# Source local changes to allow overrides\n# if needed\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"`\n\n";
227227
};
228-
08A4A3CD28434E44B6B9DE2E /* [CP] Check Pods Manifest.lock */ = {
228+
03F222F555AA5FCA86EF177B /* [Expo] Configure project */ = {
229229
isa = PBXShellScriptBuildPhase;
230+
alwaysOutOfDate = 1;
230231
buildActionMask = 2147483647;
231232
files = (
232233
);
233234
inputFileListPaths = (
234235
);
235236
inputPaths = (
236-
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
237-
"${PODS_ROOT}/Manifest.lock",
238237
);
239-
name = "[CP] Check Pods Manifest.lock";
238+
name = "[Expo] Configure project";
240239
outputFileListPaths = (
241240
);
242241
outputPaths = (
243-
"$(DERIVED_FILE_DIR)/Pods-expoexample-checkManifestLockResult.txt",
244242
);
245243
runOnlyForDeploymentPostprocessing = 0;
246244
shellPath = /bin/sh;
247-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
248-
showEnvVarsInLog = 0;
245+
shellScript = "# This script configures Expo modules and generates the modules provider file.\nbash -l -c \"./Pods/Target\\ Support\\ Files/Pods-expoexample/expo-configure-project.sh\"\n";
249246
};
250-
15F278EF833B933853C8ECB8 /* [Expo] Configure project */ = {
247+
08A4A3CD28434E44B6B9DE2E /* [CP] Check Pods Manifest.lock */ = {
251248
isa = PBXShellScriptBuildPhase;
252-
alwaysOutOfDate = 1;
253249
buildActionMask = 2147483647;
254250
files = (
255251
);
256252
inputFileListPaths = (
257253
);
258254
inputPaths = (
255+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
256+
"${PODS_ROOT}/Manifest.lock",
259257
);
260-
name = "[Expo] Configure project";
258+
name = "[CP] Check Pods Manifest.lock";
261259
outputFileListPaths = (
262260
);
263261
outputPaths = (
262+
"$(DERIVED_FILE_DIR)/Pods-expoexample-checkManifestLockResult.txt",
264263
);
265264
runOnlyForDeploymentPostprocessing = 0;
266265
shellPath = /bin/sh;
267-
shellScript = "# This script configures Expo modules and generates the modules provider file.\nbash -l -c \"./Pods/Target\\ Support\\ Files/Pods-expoexample/expo-configure-project.sh\"\n";
266+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
267+
showEnvVarsInLog = 0;
268268
};
269269
800E24972A6A228C8D4807E9 /* [CP] Copy Pods Resources */ = {
270270
isa = PBXShellScriptBuildPhase;
@@ -296,7 +296,7 @@
296296
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-expoexample/Pods-expoexample-resources.sh\"\n";
297297
showEnvVarsInLog = 0;
298298
};
299-
EC3CC923263A7AEA31493FDC /* [CP] Embed Pods Frameworks */ = {
299+
E7AB3CAEC83848EFF07424DB /* [CP] Embed Pods Frameworks */ = {
300300
isa = PBXShellScriptBuildPhase;
301301
buildActionMask = 2147483647;
302302
files = (
@@ -326,7 +326,7 @@
326326
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */,
327327
13B07FC11A68108700A75B9A /* main.m in Sources */,
328328
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */,
329-
963CF31A941C4CD3A9357BE8 /* noop-file.swift in Sources */,
329+
71C7831EDF474CEBAD2BE216 /* noop-file.swift in Sources */,
330330
);
331331
runOnlyForDeploymentPostprocessing = 0;
332332
};

ios/cbl-js-swift

0 commit comments

Comments
 (0)