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

Can't find by REGEXP. Help please! #51

Open
maximniko opened this issue Oct 17, 2017 · 0 comments
Open

Can't find by REGEXP. Help please! #51

maximniko opened this issue Oct 17, 2017 · 0 comments

Comments

@maximniko
Copy link

maximniko commented Oct 17, 2017

I try get some model by some regexp

func (dao *SomeModelDAO) findListNumbers(rs app.RequestScope, someModel *models.SomeModel, regexp string) error {
	err := rs.Tx().Select("id", "number").
		From("someModel s").
		AndWhere(dbx.NewExp("s.number REGEXP {:regexp}", dbx.Params{"regexp": regexp})).
		OrderBy("s.id DESC").
		GroupBy("s.id").
		Limit(1).
		One(&someModel)

	return err
}

From this code my regexp string is "'^(AA)(0000)(AA)$'"
But in Command Line Tools Console in PhpStorm I see this query

SELECT `id`, `number` FROM `sumeModel` `s` WHERE s.number REGEXP '''^(AA)(1234)(II)$''' GROUP BY `s`.`id` ORDER BY `s`.`id` DESC LIMIT 1

And I can find Nothing from my db because of unnecessary characters
REGEXP '''^(AA)(1234)(II)$''' will be REGEXP '^(AA)(1234)(II)$'
How to solve this problem?

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

1 participant