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

Add feature LIKE & NOT LIKE condition. #103

Closed
wants to merge 2 commits into from

Conversation

kpango
Copy link

@kpango kpango commented Sep 15, 2017

Add LIKE & NOT LIKE feature to condition.go for fuzzy search using LIKE

LIKE syntax is below
SELECT * FROM `table` WHERE `a` LIKE "%value%";
val := `%value%`
dbr.Select("*").From("table").Where(dbr.Like("a", val))
NOT LIKE syntax is below
SELECT * FROM `table` WHERE `b` NOT LIKE "%value%";
val := `%ng_value%`
dbr.Select("*").From("table").Where(dbr.NotLike("b", val))

this is the same as #75 contents

condition.go Outdated

func buildLikeCmp(d Dialect, buf Buffer, pred string, column string, value interface{}) error {
if value == nil {
return ErrColumnNotSpecified
Copy link
Contributor

Choose a reason for hiding this comment

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

ErrColumnNotSpecified is not for this.

condition.go Outdated
}
fallthrough
default:
return ErrColumnNotSpecified
Copy link
Contributor

Choose a reason for hiding this comment

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

ErrColumnNotSpecified is not for this

case reflect.Ptr, reflect.Interface: // pointer or interface
// for pointers & interfaces check
return buildLikeCmp(d, buf, pred, column, v.Elem().Interface())
case reflect.Slice:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems weird to me to support slice. Could you explain?

Copy link
Author

Choose a reason for hiding this comment

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

It is an implementation that takes into consideration that byte slice or rune slice comes in

@simonmeusel
Copy link

simonmeusel commented Feb 1, 2018

What's the status of this pr?

@andrew310
Copy link

will this be merged? it seems like a useful feature...

@kpango kpango force-pushed the feature-like-not-like-condition branch from 66668ec to b70ec46 Compare August 14, 2018 04:27
@kpango kpango force-pushed the feature-like-not-like-condition branch from b70ec46 to 8f3da24 Compare August 14, 2018 04:35
@mccolljr
Copy link
Contributor

mccolljr commented Sep 8, 2018

Wanted to check in here - will this be merged?

@taylorchu
Copy link
Contributor

#147

@taylorchu taylorchu closed this Sep 27, 2018
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.

5 participants