![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/petroviliya/mysql_query_builder
Query Builder makes it easier to build queries for MySQL databases.
So, if your application relies heavily on MySQL database and using the repository pattern is too expensive for performance, then you should use query services in which you need to build optimized queries. This query builder will help you build large and readable queries
github.com/PetrovIliya/mysql_query_builder v1.0.1beta
to your go.mod fileqb "github.com/PetrovIliya/mysql_query_builder"
selectQb := qb.Select("order", "o", "mi.*")
selectQb.InnerJoin("menu_item", "mi", "mi.order_id = o.order_id")
orderIds := make([]string, 2)
orderIds[0] = "1"
orderIds[1] = "2"
selectQb.AndWhereIn("o.order_id", orderIds)
selectQb.Limit(1)
selectQb.Offset(2)
selectQb.OrderBy("o.order_id DESC")
sqlStr, err := selectQb.GetSql()
unionSubQueryQb := qb.UnionSelect("order", "o2", "o2.cost")
unionSubQueryQb.AndWhere("o2.order_id = 2")
selectQb := qb.UnionSelect("order", "o", "o.cost")
selectQb.AndWhere("o.order_id = 1")
selectQb.Union(unionSubQueryQb)
sqlStr, err := selectQb.GetSql()
updateQb := qb.Update("order", "o")
updateQb.Set("o.cost", "970")
updateQb.AndWhere("order_id = 1")
sqlStr, err := updateQb.GetSql()
updateQb := qb.Update("order", "o")
updateQb.Set("o.cost", "(SELECT o2.cost FROM `order` o2 WHERE order_id = 2)")
updateQb.AndWhere("order_id = 1")
sqlStr, err := updateQb.GetSql()
selectQb := qb.Select("order", "o", "order_id, cost")
insertQb := qb.InsertInto("order", "(order_id, cost)")
insertQb.Ignore(true)
insertQb.ValuesQuery(selectQb)
sqlStr, err := insertQb.GetSql()
unionSbQb := qb.UnionSelect("order", "o2", "order_id, cost")
selectQb := qb.UnionSelect("order", "o", "order_id, cost")
selectQb.Union(unionSbQb)
insertQb := qb.InsertInto("order", "(order_id, cost)")
insertQb.Ignore(true)
insertQb.ValuesUnionQuery(selectQb)
sqlStr, err := insertQb.GetSql()
insertQb := qb.InsertInto("order", "(order_id, cost)")
insertQb.Ignore(true)
a := make([]string, 2)
a[0] = "1"
a[1] = "3"
b := make([][]string, 1)
b[0] = a
insertQb.Values(b)
sql, err := insertQb.GetSql()
Result: INSERT IGNORE INTO `order` (order_id, cost) VALUES ('1', '3')
deleteQb := qb.Delete("menu_item", "mi", "mi.*")
deleteQb.InnerJoin("order", "o", "o.order_id = mi.order_id")
deleteQb.AndWhere("o.order_id = 1")
sqlStr, err := deleteQb.GetSql()
I like the Doctrine query builder style and PHP arrays, so I transferred my Doctrine experience to this query builder.
The usability of using go slices as parameters to some query builder methods is questionable. If this is the case let me know, and I will try to fix it for the v1.0.0 release.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.