Skip to content

How can I get the binding query? #29

Description

@gywndi

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions