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

drivers/mssql: handleSelectSqlReplacement cannot handle multiLineSql #4106

Open
sanrentai opened this issue Jan 9, 2025 · 1 comment
Open
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@sanrentai
Copy link
Contributor

sanrentai commented Jan 9, 2025

Go version

go version go1.23.4 windows/amd64

GoFrame version

2.8.3

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

// LIMIT 1
		inputSql := `SELECT a,
b
FROM User WHERE ID = 1 LIMIT 1`
		expectedSql := `SELECT TOP 1 a,
b
FROM User WHERE ID = 1`
		resultSql, err := d.handleSelectSqlReplacement(inputSql)
		t.AssertNil(err)
		t.Assert(resultSql, expectedSql)

What did you see happen?

SELECT a,
b
FROM User WHERE ID = 1 LIMIT 1

What did you expect to see?

SELECT TOP 1 a,
b
FROM User WHERE ID = 1

@sanrentai sanrentai added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jan 9, 2025
@sanrentai
Copy link
Contributor Author

目前的解决方案

func (d *Driver) handleSelectSqlReplacement(toBeCommittedSql string) (newSql string, err error) {
	toBeCommittedSql, err = gdb.FormatMultiLineSqlToSingle(toBeCommittedSql)
	if err != nil {
		return "", err
	}
.....

sanrentai added a commit to sanrentai/gf-1 that referenced this issue Jan 9, 2025
sanrentai added a commit to sanrentai/gf-1 that referenced this issue Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

1 participant