Git Product home page Git Product logo

scalasql's People

Contributors

haskiindahouse avatar lihaoyi avatar mrdziuban avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scalasql's Issues

Invalid published scalasql-core POM file (Error resolving scalasql_2.13 0.1.0)

I added the scalasql dependency to my sbt build,

    libraryDependencies ++= Seq(
      "com.lihaoyi" % "scalasql_2.13" % "0.1.0",
      ...
   )

And when SBT tries to resolve it, I get the following error:

sbt:webapp> compile
[info] Updating 
https://repo1.maven.org/maven2/com/lihaoyi/scalasql_2.13/0.1.0/scalasql_2.13-0.1.0.pom
  100.0% [##########] 2.5 KiB (8.5 KiB / s)
https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j-impl/2.20.0/log4j-slf4j-impl-2.20.0.pom
  100.0% [##########] 7.5 KiB (78.9 KiB / s)
https://repo1.maven.org/maven2/com/lihaoyi/scalasql-operations_2.13/0.1.0/scalasql-operations_2.13-0.1.0.pom
  100.0% [##########] 1.6 KiB (14.2 KiB / s)
https://repo1.maven.org/maven2/com/lihaoyi/scalasql-query_2.13/0.1.0/scalasql-query_2.13-0.1.0.pom
  100.0% [##########] 1.6 KiB (6.3 KiB / s)
https://repo1.maven.org/maven2/com/lihaoyi/scalasql-core_2.13/0.1.0/scalasql-core_2.13-0.1.0.pom
  100.0% [##########] 2.2 KiB (17.5 KiB / s)
[info] Resolved  dependencies
[warn] 
[warn] 	Note: Unresolved dependencies path:
[error] stack trace is suppressed; run last update for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-reflect:scalasql[2.13.12].scalaVersion
[error]   Not found
[error]   Not found
[error]   not found: /home/boisvert/.ivy2/local/org.scala-lang/scala-reflect/scalasql[2.13.12].scalaVersion/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/scalasql[2.13.12].scalaVersion/scala-reflect-scalasql[2.13.12].scalaVersion.pom
[error] Total time: 1 s, completed Apr 5, 2024, 6:36:08 PM

Indeed when inspecting the scalasql-core POM file at https://repo1.maven.org/maven2/com/lihaoyi/scalasql-core_2.13/0.1.0/scalasql-core_2.13-0.1.0.pom it looks like it contains the following ill-formed dependency:

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-reflect</artifactId>
            <version>scalasql[2.13.12].core.scalaVersion</version>
        </dependency>

flatMap is unsafe

Did a lot of thinking recently in my own library, and came to the conclusion that I could not implement flatMap safely for all SQL dialects. Wondered if ScalaSql was susceptible to the same, so I check, and yes. Here is an example of a query which will not run because of invalid syntax.

dbClient.renderSql(City.select.flatMap(c => City.select.sortBy(_.name).map(_ => c.id).crossJoin().map(r => r)))

Nested/Embedded datastructures possible?

Thank you for creating this!

Would it be possible to support nested or "embedded" case classes within a case class representation of a table?

non compiling example:

case class Customer[T[_]](
    name: T[String],
    address: T[Address[T[_]]]
)

object Customer extends Table[Customer]

case class Address[T[_]](
    street: T[String],
    city: T[String],
    zipCode: T[String],
    country: T[String]
)

the expected outcome in this case would be that the address value is treated as if it were flat in the customer table. this would allow sharing or reusing data structures in different contexts.

a probably better example, would be MonetaryAmount with a value and currency component. its used a lot in different places if an app commits to storing values with currency.

Maybe there is some way to hook into something like a CompositeTypeMapper where one can supply custom givens analogous to the TypeMapper typeclass

for reference, I asked a somewhat similar question in another repo: AugustNagro/magnum#24 obviously, it's tough for me to let go of that feature after years of using java's hibernate :)

Huge memory increase in `renderSql` with scala 2.13.13 (OOM)

I wanted to try this library and immediately got an OutOfMemoryError for a trivial select statement of a single row on a single table. Reducing the fields count in the table definition allowed me to run the query, but it still took several seconds to generate the query, something was clearly wrong. Reverting to scala 2.13.12 (from 2.13.13) fixed the issue, apparently the last two commit of the ArrayBuilder broke something: https://github.com/scala/scala/commits/5aa3dc5ea77800ddd2a3bdf9e7feeea57484421c/src/library/scala/collection/mutable/ArrayBuilder.scala

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.lang.reflect.Array.newArray(Native Method)
        at java.base/java.lang.reflect.Array.newInstance(Array.java:78)
        at java.base/java.util.Arrays.copyOf(Arrays.java:3514)
        at java.base/java.util.Arrays.copyOf(Arrays.java:3482)
        at scala.collection.mutable.ArrayBuilder$ofRef.mkArray(ArrayBuilder.scala:110)
        at scala.collection.mutable.ArrayBuilder$ofRef.resize(ArrayBuilder.scala:114)
        at scala.collection.mutable.ArrayBuilder.ensureSize(ArrayBuilder.scala:39)
        at scala.collection.mutable.ArrayBuilder.addAll(ArrayBuilder.scala:53)
        at scala.collection.mutable.ArrayBuilder.addAll(ArrayBuilder.scala:49)
        at scalasql.core.SqlStr$.rec$1(SqlStr.scala:102)
        at scalasql.core.SqlStr$.rec$1(SqlStr.scala:120)
        at scalasql.core.SqlStr$.rec$1(SqlStr.scala:120)
        at scalasql.core.SqlStr$.flatten(SqlStr.scala:134)
        at scalasql.query.SimpleSelect$Renderer.render(SimpleSelect.scala:271)
        at scalasql.query.CompoundSelect$Renderer.render(CompoundSelect.scala:119)
        at scalasql.query.Select.renderSql(Select.scala:193)
        at scalasql.query.Select.renderSql$(Select.scala:190)
        at scalasql.query.CompoundSelect.renderSql(CompoundSelect.scala:10)
        at scalasql.core.SqlStr$Renderable$.renderSql(SqlStr.scala:218)
        at scalasql.query.Query$Single.renderSql(Query.scala:83)
        at scalasql.query.Query$QueryQueryable.renderSql(Query.scala:72)
        at scalasql.query.Query$QueryQueryable.renderSql(Query.scala:66)
        at scalasql.core.DbApi$.unpackQueryable(DbApi.scala:112)
        at scalasql.core.DbApi$.renderSql(DbApi.scala:119)
        at scalasql.core.DbApi$Impl.renderSql(DbApi.scala:424)

Scala 3 Support (1000USD Bounty)

Currently ScalaSql only supports Scala 2.13. Getting it working on Scala 3 would involve porting the table macros, which is one ~100 line file https://github.com/com-lihaoyi/scalasql/blob/main/scalasql/query/src-2/TableMacro.scala. I don't have the knowledge of Scala 3 macros to do it myself, but it shouldn't be hard to port, and the rest of the ScalaSql library should "just work".

To incentivize contribution, I'm putting a 1000USD bounty on resolving this ticket to the first person who can get all the ScalaSql tests passing on Scala 3. This is payable via bank transfer, and at my discretion in case of ambiguity.

Using the H2Dialect, how does one retrieve auto-generated keys?

Discussed in #7

Originally posted by aboisvert April 10, 2024
The H2Dialect doesn't support the 'returning' clause, so I'm wondering what's the recommended way to retrieve auto-generated keys? (e.g. upon insert, it's typical to retrieve a row's generated primary key such as id)

This is typically done at a low-level through JdbcStatement.getGeneratedKeys but I don't see this capability available through the scalasql abstractions.
https://h2database.com/javadoc/org/h2/jdbc/JdbcStatement.html#getGeneratedKeys--

Scala reflect error

I tried importing the dependency using maven, I get this error "Could not find artifact org.scala-lang:scala-reflect:pom:scalasql[2.13.12].scalaVersion in central (https://repo.maven.apache.org/maven2)",
-tried different 2.13.x versions
-tried all the different versions of scalasql , Can I get some insights on how to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.