Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better spent learning a time-tested standard than yet another framework that may vanish tomorrow.
Qb: Database toolkit for Go
11–20 of 30 posts
Re: Qb: Database toolkit for Go
#12Earlier quoted context omitted.
Have you considered another mechanism apart from field tags for relating fields to the db (for example a function for marshalling?). It's starting to look like you're creating a dsl stuffed into struct field tags as strings, which gets ugly if it is complex. This is one part of go I'm really not keen on for this reason.
In https://github.com/aodin/sol#sol I separated the table schema, which is a function, from the destination / receiver structs. This approach allows you to build tables programmatically and do condensed selections, such as all IDs into a []int. However, this process still has to match database columns to struct field names for most selections.
Re: Qb: Database toolkit for Go
#13so this is more or less an orm for go? database toolkit is sort of ambiguous.
Re: Qb: Database toolkit for Go
#14I've tried gorm and in the end concluded that "orm" (in quotes because there are no "objects" in Go strictly speaking) does not make sense. Just writing out SQL statements old-school works much better, is quicker and easier to understand than the cognitive overhead of having to know yet another thing. Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better sp…
For example: my @movies = Schema->Movie->recent->starring("brad pitt")->all;, where recent is a method to restrict movies by age, and starring is a method to join on the actors table and restrict to a specific actor.
Re: Qb: Database toolkit for Go
#15I've tried gorm and in the end concluded that "orm" (in quotes because there are no "objects" in Go strictly speaking) does not make sense. Just writing out SQL statements old-school works much better, is quicker and easier to understand than the cognitive overhead of having to know yet another thing. Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better sp…
The biggest irritation I have is dealing with null values, but the built-in null types in the SQL package are adequate, and there are packages that make them play nice with JSON as well. JSON and array types in Postgres can also be a little cumbersome, but the database packages I've tried don't seem to properly handle them anyway.
Re: Qb: Database toolkit for Go
#16I've tried gorm and in the end concluded that "orm" (in quotes because there are no "objects" in Go strictly speaking) does not make sense. Just writing out SQL statements old-school works much better, is quicker and easier to understand than the cognitive overhead of having to know yet another thing. Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better sp…
I agree; it's a little tedious to have to write the boilerplate required, but in the end it works fine. I know exactly what queries my code is running rather than potentially being surprised by what a package/framework may be doing. The biggest irritation I have is dealing with null values, but the built-in null types in the SQL package are adequate, and there are packages that make them play nice with JSON as well.…
Re: Qb: Database toolkit for Go
#17I've tried gorm and in the end concluded that "orm" (in quotes because there are no "objects" in Go strictly speaking) does not make sense. Just writing out SQL statements old-school works much better, is quicker and easier to understand than the cognitive overhead of having to know yet another thing. Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better sp…
I find by far the most useful aspect of ORMs is the query builder, when done well. Much of the time I'm telling my ORM to output in core data types for speed anyway. Having a query builder that allows me to create my own methods for encapsulating common query actions is too useful to give up though. For example: my @movies = Schema->Movie->recent->starring("brad pitt")->all; , where recent is a method to restrict mov…
I suspect this is particular to SQLAlchemy, but if not I'd prefer just to roll my own SQL going forward.
Re: Qb: Database toolkit for Go
#18I've tried gorm and in the end concluded that "orm" (in quotes because there are no "objects" in Go strictly speaking) does not make sense. Just writing out SQL statements old-school works much better, is quicker and easier to understand than the cognitive overhead of having to know yet another thing. Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better sp…
Feedbacks & Contributions are welcome about the builder.
Re: Qb: Database toolkit for Go
#19A lot of the work involved in writing a database is systems stuff such as being sure that a commit log has actually been committed. Having a toolkit that does all that stuff for you would make it a lot easier to write your own database.
Re: Qb: Database toolkit for Go
#20I've tried gorm and in the end concluded that "orm" (in quotes because there are no "objects" in Go strictly speaking) does not make sense. Just writing out SQL statements old-school works much better, is quicker and easier to understand than the cognitive overhead of having to know yet another thing. Also, some advice: if you're looking to abstract away from SQL because you find it hard - your time is much better sp…