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

How can I get the binding query? #29

Open
gywndi opened this issue Aug 5, 2021 · 0 comments
Open

How can I get the binding query? #29

gywndi opened this issue Aug 5, 2021 · 0 comments

Comments

@gywndi
Copy link

gywndi commented Aug 5, 2021

Hi, I have some question.

I want to collect and parse queries and make statistics by query pattern.
Query patterns should be collected in this form.

## AS-IS
select * from abc where x = 1

## TO-BE
select * from abc where x = ?

As a test, I tried the following code, but a different query came out.

func main() {
	stmt, err := sqlparser.Parse("select * from user_items where user_id=1 order by created_at limit 3 offset 10")
	if err != nil {
		panic(err)
	}
	q := sqlparser.GenerateParsedQuery(stmt).Query
	fmt.Println(q)
}

But, the result is as below.

select * from user_items where user_id = 1 order by created_at asc limit 10, 3

please reply.
Thanks.
Chan.

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