-
Notifications
You must be signed in to change notification settings - Fork 32
test: fix string compliance tests #23
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
Merged
Merged
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5b1d1b1
test: fix string compliance tests
HemangChothani 0730997
fix: resolve conflict
HemangChothani 1dba2c0
test: add todo note to remove override method and resolve conflict
HemangChothani 55eebbf
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani de0732d
test: nit
HemangChothani 89ab8d5
Merge branch 'main' into fix_string_compliance_tests
larkee 210f938
test: remove select statements and resolve conflict
HemangChothani 9b52c20
test: nit
HemangChothani a08a154
fix: nit
HemangChothani 694ec7b
fix: remove override methods and add default value
HemangChothani 703f58c
fix: add default value MAX
HemangChothani 84782a0
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani 0c53c30
test: resolve conflict
HemangChothani 175535c
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani 611605c
Merge branch 'main' into fix_string_compliance_tests
AVaksman 6025d3a
Merge branch 'main' into fix_string_compliance_tests
HemangChothani 814b23a
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani ab715af
Merge branch 'fix_string_compliance_tests' of https://github.com/clou…
HemangChothani c4b9420
test: resolve conflict
HemangChothani 81bb2eb
test: resolve conflict
HemangChothani 01a85fe
test: fix nit
HemangChothani 6b0a402
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani 69cfd6b
test: add logic for additional escape ti fox the test
HemangChothani b58b718
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani bcf939c
test: add condition check for other data type
HemangChothani 3229b2c
Merge branch 'main' of https://github.com/cloudspannerecosystem/pytho…
HemangChothani 913710c
test: remove override tests
HemangChothani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect. Spanner does support strings containing `'s': https://cloud.google.com/spanner/docs/lexical#literals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the original test string with the Python client:
Input:
"""some 'text' hey "hi there" that's text"""
Output:
'some \'text\' hey "hi there" that\'s text'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, python successfully convert that string but spanner throws an error like
400 Syntax error: Expected \")\" or \",\" but got string literal \'text\' [at 1:41]\nINSERT INTO t_string (x) VALUES (\'some \'\'text\'\' hey \"hi there\" that\'\'s text\')\n
.I have tried with DBAPI with the direct string
'some \'text\' hey "hi there" that\'s text'
and it throws the same error.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spanner prod is working with these 3 strings and adding escape characters to them.
$ Report(name=r"1. backslash one \ backslash \\ two end").save()
$ Report.objects.all()[0].name
'1. backslash one \\ backslash \\\\ two end'
$ Report(name=r"2. backslash one \ backslash \ two end").save()
$ Report.objects.all()[1].name
'2. backslash one \ backslash \\ two end'
$ Report(name="""3. some 'text' hey "hi there" that's text""").save()
$ Report.objects.all()[2].name
'3. some 'text' hey "hi there" that's text'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean when it comes through the DB API it throws an error:
@vi3k6i5 if you are using spanner client directly for the insert, then for help can you share the actual sql query syntax passing at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it looks like the issue is the SQL query rather than the data string. Spanner supports both
'backslash one \ backslash \\ two end''
and"some 'text' hey "hi there" that's text'
however, when specifying these types of strings by SQL, the additional escapes are necessary.Rather than skipping these tests, we need to add additional logic to add these additional escapes before they are used to generate SQL statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the DBAPI code showing the strings are supported:
Output: