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

Fails to process Type: clause.AndConditions (after updating form & gorm-deep-filtering) #3

Open
addshore opened this issue Apr 17, 2024 · 3 comments

Comments

@addshore
Copy link

addshore commented Apr 17, 2024

I have a query that looks something like this

SELECT count(*) FROM userWHEREidIN (3872,3877) ANDusername = '*person@domain*'

When updating some packages, gorm-like appears to stop working for this query.

-       github.com/go-sql-driver/mysql v1.7.1
+       github.com/go-sql-driver/mysql v1.8.1
-       github.com/survivorbat/gorm-deep-filtering v0.0.8 (my own fork, see replace details below)
+       github.com/survivorbat/gorm-deep-filtering v0.1.1
-       gorm.io/driver/mysql v1.5.1-0.20230509030346-3715c134c25b
-       gorm.io/gen v0.3.23
-       gorm.io/hints v1.1.0
-       gorm.io/plugin/dbresolver v1.4.3
+       gorm.io/driver/mysql v1.5.6
+       gorm.io/gen v0.3.26
+       gorm.io/hints v1.1.2
+       gorm.io/plugin/dbresolver v1.5.1
-       gorm.io/gorm v1.25.3
+       gorm.io/gorm v1.25.9
-replace github.com/survivorbat/gorm-deep-filtering => github.com/addshore/gorm-deep-filtering v0.0.0-20230821122951-1f34f64d390d

I added some additional logging, and when the query gets to queryCallback, the cond.(type) is clause.AndConditions rather than either of the 2 expected values.
The value was something like Checking clause: {[{id [3872 3877]} {username *person@domain*}]}

Looking at the previous behaviourpassing through gorm-like, it would have processed 2 seperate clauses,

  • cond: {id [3872 3877]} as an IN
  • cond: {[{username LIKE ? [%person@domain%]

So it looks like perhaps I was still relying on the old wildcard behavrious in gorm-deep-filtering, but gorm-like doesnt seem to drop in as expected?

My setup has

	DB.Use(deepgorm.New())
	DB.Use(gormlike.New(gormlike.WithCharacter("*")))
@survivorbat
Copy link
Owner

Hey addshore! I somehow never found out about this github issue, so apologies for this overdue response.

A PR just went through that should fix the issue you described with the more recent gorm version clauses, could you have a look?

@addshore
Copy link
Author

Absolutly amazing!
I'll try and give upgrading another go in the coming weeks and try to remember to report back! :)
Which commit is the fix in?

@survivorbat
Copy link
Owner

v0.1.0 should have it :)

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

No branches or pull requests

2 participants