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

Named variables don't work when followed by Windows CRLF line endings #5355

Closed
clarkmcc opened this issue May 20, 2022 · 1 comment · Fixed by #5356
Closed

Named variables don't work when followed by Windows CRLF line endings #5355

clarkmcc opened this issue May 20, 2022 · 1 comment · Fixed by #5356
Assignees
Labels

Comments

@clarkmcc
Copy link
Contributor

clarkmcc commented May 20, 2022

GORM Playground Link

I've created a PR with test cases instead.

To Reproduce

Run the following query (includes the line-endings)

SELECT * FROM table
WHERE name1 = @name1
 AND name2 = @name2

Description

If a named variable is followed by Windows CRLF style line endings, the variable name will include the \r portion of the line ending which causes the variable lookup in the namedMap to fail. In my PR, I've updated the expression builder to look for \r in addition to \n.

Workaround

Put a space after the named variable so that there's a separator from this list of supported separators between the named variable and the CRLF line ending.

} else if v == ' ' || v == ',' || v == ')' || v == '"' || v == '\'' || v == '`' || v == '\n' || v == ';' {

@github-actions
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

jinzhu pushed a commit that referenced this issue May 22, 2022
…F line endings (#5356)

* Fixed #5355.

* Fixed unit test to test both CRLF and CR line endings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants