Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC-8272-C4-Apple --Swift/ObjC N1QL Code Snippets #534

Merged
merged 2 commits into from
Sep 15, 2021

Conversation

ibsoln
Copy link
Contributor

@ibsoln ibsoln commented Sep 11, 2021

Comment on lines +1836 to +1842
NSString *n1qlstr = "SELECT * FROM _ WHERE type = $type"; // <.>

CBLQuery* thisQuery = [db createQuery: n1qlstr];

CBLQueryParameters* n1qlparams = [[CBLQueryParameters alloc] init];
[params setString: @"hotel" forName: @"type"]; // <.>

thisQuery.parameters = n1qlparams;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think this is correct!

But something like the below is a way to set a dynamic variable value to a N1QL query.

NSString* typeVar = @"hotel";
NSString *n1qlstr = [NSString stringWithFormat: @"SELECT * FROM dbName WHERE type = %@", typeVar];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Neat trick. Not sure Jay. I thought that we were supposed to use the Query parameters ... maybe both work, but which do we want people using? I'll follow this up and change asap.

Copy link
Contributor

@jayahariv jayahariv Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibsoln I don't think this code will work, using QueryParams!

Copy link
Contributor

@jayahariv jayahariv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check the comments.

@ibsoln ibsoln merged commit d606163 into couchbase:release/3.0 Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants