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

Wrong functionality with parametrization and error handling in Raw #6491

Closed
Petr-Markvart opened this issue Aug 1, 2023 · 4 comments
Closed
Assignees
Labels

Comments

@Petr-Markvart
Copy link

GORM issue with different processing time

See code:

	log.Printf("Test 1")
	var resultCount int64
	e.GormDB.Raw("select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = 'AMCOVSB24ER5'").Scan(&resultCount)
	log.Printf("Test 2 - count: %d", resultCount)
	e.GormDB.Raw("select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = ?", filter.InstrumentIdentifier[0]).Scan(&resultCount)
	log.Printf("Test 3 - count: %d", resultCount)
	e.GormDB.Raw("select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = '?'", filter.InstrumentIdentifier[0]).Scan(&resultCount)
	log.Printf("Test 4 - count: %d", resultCount)

Description

Test 2)
When I call statement without passing parameter I have very fast response (3 ms)
Test 3)
When I pass parameter by sign ?, it will response within 14 seconds.
Test 4)
When I pass parameter into '' it will lead to wrong syntax, but no error is reported and count response with 0.

2023/08/01 16:37:29 Test 1

2023/08/01 16:37:29 C:/Sandbox/rdh_esma/api-go/repository/sqlDbRepository.go:149 SLOW SQL >= 1ms
[2.565ms] [rows:1] select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = 'AMCOVSB24ER5'
2023/08/01 16:37:29 Test 2 - count: 1

2023/08/01 16:37:44 C:/Sandbox/rdh_esma/api-go/repository/sqlDbRepository.go:151 SLOW SQL >= 1ms
[14395.022ms] [rows:1] select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = 'AMCOVSB24ER5'
2023/08/01 16:37:44 Test 3 - count: 1

2023/08/01 16:37:44 C:/Sandbox/rdh_esma/api-go/repository/sqlDbRepository.go:153 SLOW SQL >= 1ms
[2.562ms] [rows:1] select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = ''AMCOVSB24ER5''
2023/08/01 16:37:44 Test 4 - count: 0

@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Aug 1, 2023
@github-actions
Copy link

github-actions bot commented Aug 1, 2023

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

@Petr-Markvart
Copy link
Author

Petr-Markvart commented Aug 9, 2023

It looks like issue with usage of DB table indexes. It was query from table with millions of rows. We are using Azure SQL DB. Moved to different solution without Gorm library and it works fine for us.
Any way I can see issue with wrong handling query where is bad syntax (case 4).

We are using:
github.com/microsoft/go-mssqldb v1.3.0
gorm.io/driver/sqlserver v1.5.1
gorm.io/gorm v1.25.2

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

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

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants