Language request: Google SQL
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
Also known as Google Standard SQL, in use in BigQuery
It seems that Google Standard SQL can be considered as an alias of MySQL. Do you find any difference in SQL syntax?
@raphaelfff I'm still looking forward to your feedback. Per my investigation, we can build Google SQL with MySQL flavor. And we can use SQL() method to build non-standard SQL syntax. If you find any difficulty to build SQL using MySQL, feel free to reopen this issue and let me know.
Sorry, completly missed that
One difference i can notice is the way params are handled, in MySQL ? is used, whereas in bigquery all params are named, and refered to as @paramname in the SQL query
@raphaelfff Do you use go-sql-spanner as the SQL driver?
If so, the @paramname is a named parameter created by sql.Named(). SQL builder supports it. See Use sql.Named in a builder for more details.
the trick is that i really want consumer to not have to worry about named params, but rather have the interface behave as unnamed params, but have the name generated magically @param1 etc
I'm not sure why you need to worry about the named params. Maybe you can show me some code and then I can understand your need better.
Here are some samples showing how to use this packages with github.com/googleapis/go-sql-spanner.
The method QueryContext/ExecContext in github.com/googleapis/go-sql-spanner supports ? as placeholder, you can build SQL like following.
sb := sqlbuilder.Select("id", "text").From("tweets")
sb.Where(sb.GreaterThan("likes", 500))
sql, args := sb.Build()
// db.QueryContext(ctx, "SELECT id, text FROM tweets WHERE likes > ?", 500)
db.QueryContext(ctx, sql, ...args)
Or, you can use @paramname with sql.Named() like following.
builder := sqlbuilder.DeleteFrom("tweets")
builder.Where(builder.Equal("id", sql.Named("id", 14544498215374)))
sql, args := builder.Build()
// db.ExecContext(ctx, "DELETE FROM tweets WHERE id = @id", sql.Named("id", 14544498215374))
db.ExecContext(ctx, sql, ...args)
Hope these samples can help you.