-
Notifications
You must be signed in to change notification settings - Fork 409
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
Make escaping strings more consistent. #7059
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c1d90b4
Make escaping strings more consistent.
dnwpark 9593b23
Add unescape_string and fix migration tests.
dnwpark 459995b
Fix json when selecting migration description.
dnwpark 717749c
Fix formatting.
dnwpark 949e5d4
Remove python string escaping json description.
dnwpark 76e7cb6
Add escape for double quote.
dnwpark 251d3c9
Remove unescape_string.
dnwpark 714fd4d
Remove separate escape_string function.
dnwpark b79c7b2
Remove double quote escape.
dnwpark a10f228
Fix test.
dnwpark 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 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# This source file is part of the EdgeDB open source project. | ||
# | ||
# Copyright 2016-present MagicStack Inc. and the EdgeDB authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
|
||
import unittest | ||
|
||
|
||
def suite(): | ||
test_loader = unittest.TestLoader() | ||
test_suite = test_loader.discover('.', pattern='test_*.py') | ||
return test_suite |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# This source file is part of the EdgeDB open source project. | ||
# | ||
# Copyright 2018-present MagicStack Inc. and the EdgeDB authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import unittest | ||
|
||
import edb.edgeql.quote as qlquote | ||
|
||
class QuoteTests(unittest.TestCase): | ||
|
||
def test_quote_string(self): | ||
self.assertEqual(qlquote.quote_literal(""), "''"), | ||
self.assertEqual(qlquote.quote_literal("abc"), "'abc'") | ||
self.assertEqual(qlquote.quote_literal("\""), "'\"'") | ||
self.assertEqual(qlquote.quote_literal("\b"), "'\\b'") | ||
self.assertEqual(qlquote.quote_literal("\f"), "'\\f'") | ||
self.assertEqual(qlquote.quote_literal("\n"), "'\\n'") | ||
self.assertEqual(qlquote.quote_literal("\r"), "'\\r'") | ||
self.assertEqual(qlquote.quote_literal("\t"), "'\\t'") | ||
self.assertEqual(qlquote.quote_literal("\'"), "'\\\''") | ||
self.assertEqual(qlquote.quote_literal("\\"), "'\\\\'") | ||
self.assertEqual(qlquote.quote_literal("\\b"), "'\\\\b'") | ||
self.assertEqual(qlquote.quote_literal("\\f"), "'\\\\f'") | ||
self.assertEqual(qlquote.quote_literal("\\n"), "'\\\\n'") | ||
self.assertEqual(qlquote.quote_literal("\\r"), "'\\\\r'") | ||
self.assertEqual(qlquote.quote_literal("\\t"), "'\\\\t'") | ||
self.assertEqual(qlquote.quote_literal("\\\'"), "'\\\\\\\''") | ||
self.assertEqual(qlquote.quote_literal("\\\\"), "'\\\\\\\\'") | ||
self.assertEqual(qlquote.quote_literal( | ||
"abc\"efg\nhij\'klm\\nop"), | ||
"'abc\"efg\\nhij\\\'klm\\\\nop'") |
Oops, something went wrong.
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.
Should we make this table driven?
(Or maybe just not bother)