orangy / squash

SQL access DSL for Kotlin
265 stars 16 forks source link

The sample code for querying tables looks incorrect #6

Open ndchorley opened 6 years ago

ndchorley commented 6 years ago

In the readme, there is

object Citizens : TableDefinition() {
    val id = varchar("id", 10).primaryKey()
    val name = varchar("name", length = 50)
    val cityId = reference(Cities.id, "city_id").nullable()
}
...

val row = query(Citizens)
...

This won't compile - query takes an argument of type QueryObject and TableDefinition doesn't inherit from that.

jstr14 commented 6 years ago

Same error here, @orangy Can you explain us something about it?

rascala commented 6 years ago

Looks like you'd have to use "from" from(Citizens).select(Citizens.name, Citizens.id).where { Citizens.name eq "name" }

I'm looking at the benchmarks file: https://github.com/orangy/squash/blob/master/squash-benchmarks/src/org/jetbrains/squash/benchmarks/QueryBenchmark.kt

orangy commented 6 years ago

May be you need to import another package – there are few query functions there, and that's something we should fix.

brezinajn commented 6 years ago

I'm not able to find correct query import. Would you please provide the correct import?

orangy commented 6 years ago

Yes, @rascala was right, and I was wrong. You need from there.

codesplode commented 5 years ago

Just going through issues and it looks like this is already done. @orangy , anything else you'd like done in order to close this issue? I can certainly provide more examples and documentation now that I've found my way around if you like.