-
Notifications
You must be signed in to change notification settings - Fork 17
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
How to SELECT *? #27
Comments
select statements are parameterised by the types of the columns that are being selected. This means you can write Writing If you want to fetch all of the columns for a table then a possible workaround would be to define class MyTable(alias: Option[String]) extends Table("mytable", alias) {
val col1 = column[Int]("col1")
val col2 = column[String]("col2")
val * = (col1, col2)
}
object MyTable extends MyTable(None) You would then be able to write I've create a branch select-star with a first stab of changing the select statement to allow this. You can see it in action here: https://github.com/jhc-systems/sqlest/blob/select-star/sqlest/src/test/scala/sqlest/executor/ExecutorSpec.scala#L72. Note this wouldn't work if you wanted to select * from multiple tables What do you think? |
I see. The only issue with the |
nm the 22 limit, I just figured out that I can use the following style too BTW, why is the |
You can't actually run a select statement that uses the In fact if you try you will get a compilation error. This is because you can only use the def fetchHead[SingleResult](implicit extractable: Extractable.Aux[ResultSet, A, SingleResult]): SingleResult = ... There is no Extractable typeclass instance for Your other suggestion to use an HList is definitely the way to go. However I think it would be dangerous to make the API to sqlest depend on an external library - people using different versions would not be able to use the project . However by implementing the Extractable typeclass for HList you will be able to do this I'll make some changes to enable doing this and create an example |
That figures, I was getting the compilation error when trying to use the tuple style apply method. As far as the HList and 22 limit, I gave it some thought and it might not be that useful of a feature. After all Scala case classes can't have more than 22 fields, so you won't be able to use it anyways. |
@kutchar The restriction on 22 fields in case classes was removed in scala 2.11. |
@hrj good to know. Thanks. |
Unfortunately sqlest doesn't currently support case classes with more that 22 columns |
I couldn't figure out how I can run a
SELECT *
. I would assume thatselect()
(without providing column names) would meanSELECT *
by default.The text was updated successfully, but these errors were encountered: