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

ParsingFailureExceptions thrown when creating brewery_id index in Couchbase.Linq.IntegrationTests #348

Open
jeffrymorris opened this issue Jul 30, 2021 · 3 comments · Fixed by #352
Assignees

Comments

@jeffrymorris
Copy link
Contributor

While upgrading the CouchbaseNetClient dependency to 3.2.0, a number of integration tests (JoinTests_InnerJoin_IndexJoin, JoinTests_LeftJoin_IndexJoin, etc) are failing with ParsingFailureExceptions. For example the request:

{"statement":"CREATE INDEX brewery_id ON beer-sample(brewery_id) USING GSI WITH {\"defer_build\":False};","client_context_id":"07f299f0-0ac5-4ddd-bf2c-aac64fb3e777"}

Fails with the following response:

{
"requestID": "127a687a-bd85-4db5-8437-8a87e2f4a1d1",
"clientContextID": "07f299f0-0ac5-4ddd-bf2c-aac64fb3e777",
"errors": [{"code":3000,"msg":"syntax error - at -"}],
"status": "fatal",
"metrics": {"elapsedTime": "578.8µs","executionTime": "468.4µs","resultCount": 0,"resultSize": 0,"serviceLoad": 2,"errorCount": 1}
}

The issue appears to be that the bucket name is not being escaped with back ticks: "beer-sample" should be "`beer-sample`". This can be confirmed by running the query in the request in the query console in CB.

Note this happens for 3.0.7 and for 3.2.0 versions and I suspect all 3.X versions.

@brantburnett shouldn't this escaping be happening by the N1QlHelpers.EscapeIdentifier: https://github.com/couchbaselabs/Linq2Couchbase/blob/master/Src/Couchbase.Linq/QueryGeneration/N1QLQueryModelVisitor.cs#L137

Note that you may have to drop brewer_id index first: DROP INDEX brewery_id on `beer-sample

Jeff

@brantburnett
Copy link
Collaborator

@jeffrymorris

I was waiting to fix this on the resolution to this issue since the consensus was that the SDK should be doing the backtick wrapping. I didn't want to come back and undo the change later.

@jeffrymorris
Copy link
Contributor Author

@brantburnett -

I guess I dropped the ball on this one - looks like this one should have been in the queue and released long ago. I'll assign the ticket to 3.2.1 and get it resolved.

-Jeff

@brantburnett brantburnett self-assigned this Aug 2, 2021
brantburnett added a commit that referenced this issue Aug 3, 2021
Motivation
----------
The current approach to string escaping causes problems if a backslash
is included, and also can't handle special characters like tab or CR.

Modifications
-------------
Serialize string and character constants to the N1QL query using a JSON
serializer.

Also change some other locations rendering strings to use double quotes
for consistency.

Results
-------
String and character constant expressions now support the full set of
characters supported by JSON.

Strings now appear on the query wrapped in double quotes instead of
single quotes.

Fixes #348
brantburnett added a commit that referenced this issue Aug 3, 2021
Motivation
----------
The current approach to string escaping causes problems if a backslash
is included, and also can't handle special characters like tab or CR.

Modifications
-------------
Serialize string and character constants to the N1QL query using a JSON
serializer.

Also change some other locations rendering strings to use double quotes
for consistency.

Results
-------
String and character constant expressions now support the full set of
characters supported by JSON.

Strings now appear on the query wrapped in double quotes instead of
single quotes.

Fixes #348
jeffrymorris pushed a commit that referenced this issue Aug 9, 2021
Motivation
----------
The current approach to string escaping causes problems if a backslash
is included, and also can't handle special characters like tab or CR.

Modifications
-------------
Serialize string and character constants to the N1QL query using a JSON
serializer.

Also change some other locations rendering strings to use double quotes
for consistency.

Results
-------
String and character constant expressions now support the full set of
characters supported by JSON.

Strings now appear on the query wrapped in double quotes instead of
single quotes.

Fixes #348
@brantburnett
Copy link
Collaborator

Linked to wrong issue, reopening

@brantburnett brantburnett reopened this Aug 9, 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 a pull request may close this issue.

2 participants