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

Automatically concatenate adjacent string literals #253

Merged
merged 9 commits into from
Jul 7, 2023

Conversation

zachmu
Copy link
Member

@zachmu zachmu commented Jul 7, 2023

Fixes dolthub/dolt#5232

This is to match the mysql behavior:

mysql> select "a" 'b'   "c";
+-----+
| a   |
+-----+
| abc |
+-----+

The grammar can't accommodate this so it has to go in the lexer. It doesn't work if the strings are broken up by a mysql special comment, so we still have to special case that.

Also removed support for using string literals as table aliases. MySQL has a mode to support using double-quoted strings only as identifiers, but it's not on by default and isn't supported anywhere else in the grammar.

Copy link

@fulghum fulghum left a comment

Choose a reason for hiding this comment

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

Nice fix! 🚢

Comment on lines +3363 to +3370
func TestSingle(t *testing.T) {
validSQL = append(validSQL, validMultiStatementSql...)
for _, tcase := range validSQL {
if tcase.input == "select \"'ain't'\", '\"hello\"' from t" {
runParseTestCase(t, tcase)
}
}
}
Copy link

Choose a reason for hiding this comment

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

Did you mean to leave this in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's handy for testing

@zachmu zachmu merged commit 241b093 into main Jul 7, 2023
4 checks passed
@Hydrocharged Hydrocharged deleted the zachmu/string-concat branch February 7, 2024 13:44
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.

Support implicit string concatenation
2 participants