nullism / bqb Goto Github PK
View Code? Open in Web Editor NEWBQB is a lightweight and easy to use query builder that works with sqlite, mysql, mariadb, postgres, and others.
License: MIT License
BQB is a lightweight and easy to use query builder that works with sqlite, mysql, mariadb, postgres, and others.
License: MIT License
The
set-output
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
I am really enjoying this project.
One issue I noticed very early is that if there's an error in a separate subquery it does not propagate when added to an outer query.
See this test I wrote to illustrate the issue
func TestErrorSubquery(t *testing.T) {
// One more ? than we are passing args for which is wrong and should fail
subQuery := New("SELECT id FROM table2 WHERE id = ? and value = ?", 1)
// It gives an error when the query is directly turned to sql which is good
_, _, err := subQuery.ToSql()
if err == nil || !strings.Contains(err.Error(), "extra ? in text") {
t.Errorf("expected error for subquery")
}
// But if you pass it into another query instead there is no error and the sql it spits out will be
// "SELECT * FROM table WHERE id IN ()" which is not what I would expect
q := New("SELECT * FROM table WHERE id IN (?)", subQuery)
_, _, err = q.ToSql()
if err == nil {
// It fails here
t.Errorf("expected error for subquery")
}
}
Is it possible to get it to check the sub queries for errors and return those instead of ignoring them?
I have a query with over 10000 parameters in "names", unfortunately, I have a usecase with 10000 ids in IN statement. And query.ToMysql() takes 3 mins to return the results. Is there any recommendation for the number of parameters?
My code is like:
deviceUUIDFromValue := bqb.New(`
SELECT device_id FROM devices_parameters
WHERE TYPE = ?
AND value IN (?)`, sourceTypeMap[type], names)
filterForEnvOperator := createEnvIDQuery(request.EnvOperatorMap)
deviceUUIDFromOperator := bqb.New(`
SELECT device_id FROM devices_operators
WHERE device_id IN (?) ?`, deviceUUIDFromValue, filterForEnvOperator)
query := bqb.New(`
SELECT t1.data, t2.value, t3.operator_id, t3.env_id FROM audit_device t1
JOIN devices_parameters t2 ON t2.device_id = t1.device_id
JOIN devices_operators t3 ON t3.device_id = t1.device_id
WHERE t1.device_id IN (?)
ORDER BY t1.id DESC`, deviceUUIDFromOperator)
sql, params, err := query.ToMysql()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.