-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #665 from mxl/fix-594
Fix encoders and decoders for java.util.UUID.
- Loading branch information
Showing
38 changed files
with
279 additions
and
185 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
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
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
16 changes: 16 additions & 0 deletions
16
quill-async/src/main/scala/io/getquill/context/async/UUIDObjectEncoding.scala
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,16 @@ | ||
package io.getquill.context.async | ||
|
||
import java.util.UUID | ||
|
||
trait UUIDObjectEncoding { | ||
this: AsyncContext[_, _, _] => | ||
|
||
implicit val uuidEncoder: Encoder[UUID] = encoder[UUID](SqlTypes.UUID) | ||
|
||
implicit val uuidDecoder: Decoder[UUID] = | ||
AsyncDecoder(SqlTypes.UUID)( | ||
(index: Index, row: ResultRow) => row(index) match { | ||
case value: UUID => value | ||
} | ||
) | ||
} |
16 changes: 16 additions & 0 deletions
16
quill-async/src/main/scala/io/getquill/context/async/UUIDStringEncoding.scala
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,16 @@ | ||
package io.getquill.context.async | ||
|
||
import java.util.UUID | ||
|
||
trait UUIDStringEncoding { | ||
this: AsyncContext[_, _, _] => | ||
|
||
implicit val uuidEncoder: Encoder[UUID] = encoder[UUID]((v: UUID) => v.toString, SqlTypes.UUID) | ||
|
||
implicit val uuidDecoder: Decoder[UUID] = | ||
AsyncDecoder(SqlTypes.UUID)( | ||
(index: Index, row: ResultRow) => row(index) match { | ||
case value: String => UUID.fromString(value) | ||
} | ||
) | ||
} |
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
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,17 @@ | ||
package io.getquill | ||
|
||
import java.io.Closeable | ||
import javax.sql.DataSource | ||
|
||
import com.typesafe.config.Config | ||
import io.getquill.context.jdbc.{ JdbcContext, UUIDStringEncoding } | ||
import io.getquill.util.LoadConfig | ||
|
||
class H2JdbcContext[N <: NamingStrategy](dataSource: DataSource with Closeable) | ||
extends JdbcContext[H2Dialect, N](dataSource) with UUIDStringEncoding { | ||
|
||
def this(config: JdbcContextConfig) = this(config.dataSource) | ||
def this(config: Config) = this(JdbcContextConfig(config)) | ||
def this(configPrefix: String) = this(LoadConfig(configPrefix)) | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
quill-jdbc/src/main/scala/io/getquill/MysqlJdbcContext.scala
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,17 @@ | ||
package io.getquill | ||
|
||
import java.io.Closeable | ||
import javax.sql.DataSource | ||
|
||
import com.typesafe.config.Config | ||
import io.getquill.context.jdbc.{ JdbcContext, UUIDStringEncoding } | ||
import io.getquill.util.LoadConfig | ||
|
||
class MysqlJdbcContext[N <: NamingStrategy](dataSource: DataSource with Closeable) | ||
extends JdbcContext[MySQLDialect, N](dataSource) with UUIDStringEncoding { | ||
|
||
def this(config: JdbcContextConfig) = this(config.dataSource) | ||
def this(config: Config) = this(JdbcContextConfig(config)) | ||
def this(configPrefix: String) = this(LoadConfig(configPrefix)) | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
quill-jdbc/src/main/scala/io/getquill/PostgresJdbcContext.scala
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,17 @@ | ||
package io.getquill | ||
|
||
import java.io.Closeable | ||
import javax.sql.DataSource | ||
|
||
import com.typesafe.config.Config | ||
import io.getquill.context.jdbc.{ JdbcContext, UUIDObjectEncoding } | ||
import io.getquill.util.LoadConfig | ||
|
||
class PostgresJdbcContext[N <: NamingStrategy](dataSource: DataSource with Closeable) | ||
extends JdbcContext[PostgresDialect, N](dataSource) with UUIDObjectEncoding { | ||
|
||
def this(config: JdbcContextConfig) = this(config.dataSource) | ||
def this(config: Config) = this(JdbcContextConfig(config)) | ||
def this(configPrefix: String) = this(LoadConfig(configPrefix)) | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
quill-jdbc/src/main/scala/io/getquill/SqliteJdbcContext.scala
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,17 @@ | ||
package io.getquill | ||
|
||
import java.io.Closeable | ||
import javax.sql.DataSource | ||
|
||
import com.typesafe.config.Config | ||
import io.getquill.context.jdbc.{ JdbcContext, UUIDStringEncoding } | ||
import io.getquill.util.LoadConfig | ||
|
||
class SqliteJdbcContext[N <: NamingStrategy](dataSource: DataSource with Closeable) | ||
extends JdbcContext[SqliteDialect, N](dataSource) with UUIDStringEncoding { | ||
|
||
def this(config: JdbcContextConfig) = this(config.dataSource) | ||
def this(config: Config) = this(JdbcContextConfig(config)) | ||
def this(configPrefix: String) = this(LoadConfig(configPrefix)) | ||
|
||
} |
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.