ozzo-dbx icon indicating copy to clipboard operation
ozzo-dbx copied to clipboard

Can't find by REGEXP. Help please!

Open maximniko opened this issue 8 years ago • 0 comments

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?

maximniko avatar Oct 17 '17 14:10 maximniko