GithubHelp home page GithubHelp logo

sqltyped's People

Contributors

jonifreeman avatar timorantalaiho avatar vdichev 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sqltyped's Issues

Can't read schema 'x'. Schema name can be configured...

image

Using PostgreSQL. Driver: postgresql-42.0.0.jar. I built by project using SBT "hello" and working my way from there. Also using sbt-eclipse to create Eclipse project definitions (added system properties to eclipse.ini, added the driver's jar file to my system's PATH variable for it to be able to find the PostgreSQL driver). I'm trying to use Eclipse to run my project, but the same happens using SBT from console. I'm quite the noob, but I've tried collecting as much info as possible.
The database is hosted locally and is called tut_sqltyped1, with a schema named public. Doesn't matter if I omit the schema property or not.

image

SBT build:
import Dependencies._

lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "dk.stldev.tut",
scalaVersion := "2.11.8",
version := "0.1.0-SNAPSHOT",
crossScalaVersions := Seq("2.12.2", "2.11.0")
)),
name := "Hello",
libraryDependencies += scalaTest % Test,
libraryDependencies += "fi.reaktor" % "sqltyped_2.11" % "0.4.3"
)

initialize ~= { _ =>
System.setProperty("sqltyped.url", "jdbc:postgresql://localhost:5432/tut_sqltyped1")
System.setProperty("sqltyped.driver", "org.postgresql.Driver")
System.setProperty("sqltyped.username", "postgres")
System.setProperty("sqltyped.password", "todoroot")
}

Use embedded shapeless 2.0?

Is there any chance shapeless can be "embedded" under the sqltyped package so as to allow the use with libraries dependent on shapeless 1.x? (ie, spray uses shapeless 1.x and there is little chance it well get upgraded anytime soon.)

Any aggregate functions fail on non-mysql due to empty dataTypes

Any SQL functions like distinct, count, etc. (and maybe others) cause the following error because the default dataTypes list is empty:

exception during macro expansion:
[error] java.lang.UnsupportedOperationException: empty.reduceLeft
[error]         at scala.collection.LinearSeqOptimized$class.reduceLeft(LinearSeqOptimized.scala:124)
[error]         at scala.collection.immutable.List.reduceLeft(List.scala:84)
[error]         at sqltyped.SqlParser$class.dataType(parser.scala:168)

q() map (_ get "name") - get value from result

I can't seem to get this to compile.

Code:

  val q = sql("select * from users") // two columns: "name" and "comment"
  println("1 Query: "+q.sql)
  println("Returns: ")  
  q() map (_ get "name") // won't compile

Error message:

value get is not a member of shapeless.::[String with shapeless.labelled.KeyTag[String("name"),String],shapeless.::[String with shapeless.labelled.KeyTag[String("comment"),String],shapeless.HNil]]

image

Where and how to set system property 'sqltyped.url' in a project?

Hello,

I would like to use sqltyped with Liftweb framework. However there is no build.scala file, only build.sbt.
I have added sqltyped to the dependencies, but there is an error when I use 'sql' command. For example;
val personNames = sql("SELECT name FROM person")

And the error is;
System property 'sqltyped.url is required to get a compile time connection to the database

Please suggest me how to do this. Thank you.

Issues building

Hi,
I installed typesafe stack and in demo dir dir "sbt run"

following are results

warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: fi.reaktor#sqltyped-json4s_2.10.0;0.1.0: not found
[warn] :: com.typesafe#slick_2.10.0;1.0.0-RC1: not found
[warn] :: net.databinder#unfiltered_2.10.0;0.6.4: not found
[warn] :: net.databinder#unfiltered-netty_2.10.0;0.6.4: not found
[warn] :: net.databinder#unfiltered-netty-server_2.10.0;0.6.4: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/shared/sqltyped/demo/}sqltyped-demo/*:update: sbt.ResolveException: unresolved dependency: fi.reaktor#sqltyped-json4s_2.10.0;0.1.0: not found
[error] unresolved dependency: com.typesafe#slick_2.10.0;1.0.0-RC1: not found
[error] unresolved dependency: net.databinder#unfiltered_2.10.0;0.6.4: not found
[error] unresolved dependency: net.databinder#unfiltered-netty_2.10.0;0.6.4: not found
[error] unresolved dependency: net.databinder#unfiltered-netty-server_2.10.0;0.6.4: not found
[error] Total time: 45 s, completed Jan 7, 2013 7:04:01 PM

Using symbols instead of Strings for labels

I have a commit right now which constructs records with symbols as keys instead of strings. This has advantages as some of the operations for e.g. converting to/from case classes use symbols instead of Strings. OTOH it seems that using symbols significantly degrades performance.

I was wondering whether you have had observations on Strings vs. symbols since you've chosen to use Strings and operations with symbols seem to have been available as of Shapeless 2.0 already.

If it's about performance vs. convenience, I'm also wondering on whether this should be somehow configurable. However it's currently not possible to combine different configurations like useInputTags, keys, jdbcOnly and being globally configurable might not be flexible enough. Perhaps it's worth it to expose these flags as a user might like to e.g. have a jdbcOnly, keys and symbols-as-keys settings.

Parse schema in queries

Currently using a schema to qualify the table name e.g. "SELECT * FROM schema.table" doesn't work. The parser is actually the easy part, if I just parse and ignore the schema, I get an error message of the kind "Unknown table XXX". It seems that this is because only data about the current schema is being loaded. If this is the case, what strategies might be used to get all relevant schemas? All? Lazily load the schema on first encounter? Configure schemas to load in a config file?

Consider configuration options

Currently sqltyped has several macros, each serving to pass a separate boolean parameter to the implementation: sqlj passes "jdbcOnly", sqlt passes "useInputTags" and sqlk passes "keys". I'm also wondering whether it's useful to have an option of using symbols as keys (#13) and interpolation as parameters (#14). In this case each new boolean parameter means an exponential number of combinations, leading to either too many abbreviations, e.g. sqljkt, which seems crazy, or missed combinations, e.g. I can't currently have jdbcOnly with keys, which seems like a reasonable combination. I'm wondering which other options to pass configurations you've thought about:

Obviously sqltyped is using the first 2 options, have you looked at macro annotations and if yes, do you know of any show-stoppers for using it?

String interpolation with input parameters

Some of the benefits of using String interpolation for queries is that one doesn't have to track the number and positions of params making it easier to develop, refactor and maintain. sqltyped is already using interpolation for SQL fragments. It might be worth it to implement both. For instance both Slick and Anorm use $ for parameter interpolation and #$ for "string splicing".

Any arguments for/against?

Column naming strategy

I have been playing with introducing a naming strategy for field names. If a query falls back to jdbc on Oracle, it produces something like "USER_ID" for the field name. A String -> String naming strategy would let the programmer turn that into "userId" by splitting on [^a-zA-Z], toLowerCase, title casing the tail and rejoining with empty string. Anything they want. An organization may want to whitelist "id" to be uppercase so the field in their case is "userID".

What do you think about this?

the demo doesn't compile

sbt compile
...
sbt.ResolveException: unresolved dependency: org.json4s#json4s-native_2.10;3.1.0-SNAPSHOT: not found

I think the dependency
"org.json4s" %% "json4s-native" % "3.1.0-SNAPSHOT"
in the build.scala needs to get updated to
"org.json4s" %% "json4s-native" % "3.1.0"

Cannot compile "count(*)" queries

Hey there,

count(1) works just fine. Behavior-wise, count(1) and count(*) should be identical. Here is the stack trace for a couple of lines or so:

[info] Compiling 1 Scala source to /target/scala-2.10/classes...
[error] /src/main/scala/app/utils/net/Database.scala:19: exception during macro expansion:
[error] java.lang.RuntimeException: Term AllColumns(Table(groups,None)) not supported
[error]         at scala.sys.package$.error(package.scala:27)
[error]         at sqltyped.Typer.tpeOf(typer.scala:309)
[error]         at sqltyped.TypeSigDSL$$anon$2.tpe(typesigdsl.scala:50)
...
[error]       if (sql("select count(*) from foo").apply == 0) {
[error]              ^

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.