-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support SQL arrays up to 3 dimensions
- Loading branch information
Showing
9 changed files
with
280 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ba.sake.squery | ||
|
||
// - a marker typeclass for non-scalar types | ||
// i.e. array-type and similar | ||
|
||
// - this is to prevent infinite recursion of Array[Array[Array...T | ||
// the SqlWrite, SqlRead typeclasses would break | ||
|
||
trait SqlNonScalarType[T] | ||
|
||
given [T]: SqlNonScalarType[Array[T]] = new {} | ||
given [T]: SqlNonScalarType[Seq[T]] = new {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ba.sake.squery.postgres | ||
|
||
import ba.sake.squery.write.SqlTypeName | ||
import java.util.UUID | ||
|
||
given SqlTypeName[Array[UUID]] with { | ||
def value: String = "UUID" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package ba.sake.squery.write | ||
|
||
import java.time.* | ||
|
||
// used for createArrayOf(sqlTypeName, myArray) | ||
trait SqlTypeName[T]: | ||
def value: String | ||
|
||
// for Array[Array[... T]] the value is the inner-most T name | ||
given [T](using stn: SqlTypeName[T]): SqlTypeName[Array[T]] with { | ||
def value: String = stn.value | ||
} | ||
// for Seq[Seq[... T]] the value is the inner-most T name | ||
given [T](using stn: SqlTypeName[T]): SqlTypeName[Seq[T]] with { | ||
def value: String = stn.value | ||
} | ||
|
||
given SqlTypeName[String] with { | ||
def value: String = "VARCHAR" | ||
} | ||
|
||
given SqlTypeName[Boolean] with { | ||
def value: String = "BOOLEAN" | ||
} | ||
given SqlTypeName[Byte] with { | ||
def value: String = "TINYINT" | ||
} | ||
given SqlTypeName[Short] with { | ||
def value: String = "SMALLINT" | ||
} | ||
given SqlTypeName[Int] with { | ||
def value: String = "INTEGER" | ||
} | ||
given SqlTypeName[Long] with { | ||
def value: String = "BIGINT" | ||
} | ||
given SqlTypeName[Double] with { | ||
def value: String = "REAL" | ||
} | ||
|
||
given SqlTypeName[LocalDate] with { | ||
def value: String = "DATE" | ||
} | ||
given SqlTypeName[LocalDateTime] with { | ||
def value: String = "TIMESTAMPT" | ||
} | ||
given SqlTypeName[Instant] with { | ||
def value: String = "TIMESTAMPTZ" | ||
} | ||
|
||
given SqlTypeName[Array[Byte]] with { | ||
def value: String = "BINARY" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.