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

query parameters for names, not just values #156

Open
riastradh-probcomp opened this issue Sep 16, 2015 · 5 comments
Open

query parameters for names, not just values #156

riastradh-probcomp opened this issue Sep 16, 2015 · 5 comments

Comments

@riastradh-probcomp
Copy link
Contributor

We have far too much

qcn = bql_quote_name(column_name)
cursor = bdb.execute('ESTIMATE ... %s ... FROM t' % (qcn,))

throughout the tree. We have a mechanism for query parameters to pass in values, but no mechanism for query parameters to specify the names of tables, columns, &c.

@riastradh-probcomp
Copy link
Contributor Author

Candidate syntax:

ESTIMATE @column_0, @column_1 FROM @table WHERE @column_1 = :foobar

Here @column_0, @column_1, and @table specify query parameters for names, and :foobar specifies a query parameter for a value.

@fsaad
Copy link
Collaborator

fsaad commented Sep 16, 2015

Agree with the candidate syntax, how hard is the implementation?

@riastradh-probcomp
Copy link
Contributor Author

Not sure offhand. Teaching the scanner and parser should be easy. Teaching bdb.execute to distribute parameters appropriately may be more complicated -- that's all in bql.py and compiler.py.

@tibbetts
Copy link
Contributor

Should we also be solving the problem of substituting zero or more comma separated identifiers in certain places, like

ESTIMATE @column_0, @column_1 FROM @table WHERE @column_1 = :foobar

where the number of columns isn't known a priori? How about where the structure of the predicate isn't known either?

Do we really want a string substitution language, or do we want a linq-style query builder:

bdb.table("TableName").estimate("column0","column1").where(column="foobar").execute()

@riastradh-probcomp
Copy link
Contributor Author

I was thinking of @*columns for that yesterday.

As for query builder combinators vs query parameter notation, I don't know. Query combinators will require a lot more work to do well, and while they're more composable in one specific sense, it's much clumsier to write queries with them.

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

No branches or pull requests

3 participants