Created
June 20, 2012 05:09
-
-
Save taylorleese/2958236 to your computer and use it in GitHub Desktop.
squeryl_exception
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
object TestSchema extends Schema { | |
val applicationsTable = table[Application]("applications") | |
val clientsTable = table[Client]("clients") | |
val proxyConfigsTable = table[ProxyConfig]("proxy_configs") | |
val clientWithApplications = oneToManyRelation(clientsTable, applicationsTable).via((c, a) => c.id === a.clientId) | |
val applicationWithProxyConfigs = oneToManyRelation(applicationsTable, proxyConfigsTable).via((a, h) => a.id === h.appId) | |
on(applicationsTable)(t => declare( | |
t.deleted is(indexed("app_deleted_idx")), // this line will cause an exception | |
t.deleted defaultsTo(false), // this line will also cause an exception | |
columns(t.clientId, t.appName) are(unique, indexed("app_name_idx")) | |
)) | |
on(clientsTable)(t => declare( | |
t.deleted is(indexed("client_deleted_idx")), // exception here as well | |
t.deleted defaultsTo(false), // ...and here | |
t.name is(indexed("client_name_idx")), // ...and here | |
t.clientName is(unique, indexed("domain_idx")) | |
)) | |
} | |
case class Application(@Column("client_id") clientId: ClientIdField, | |
@Column("safename") appName: AppNameField, | |
@Column("package") billingPkgId: Option[BillingPackageIdField] = none[BillingPackageIdField], | |
@Column("created_at") createdAt: Timestamp = new Timestamp(System.currentTimeMillis), | |
@Column("last_modified") lastModified: Timestamp = new Timestamp(System.currentTimeMillis), | |
@Column("deleted") deleted: Boolean = false, | |
@Column("id") override val id: AppIdField = new AppIdField(-1)) | |
extends KeyedEntity[AppIdField] { | |
def this() = this( | |
new ClientIdField(-1), | |
new AppNameField(""), | |
new BillingPackageIdField(-1).some, | |
new Timestamp(System.currentTimeMillis), | |
new Timestamp(System.currentTimeMillis), | |
false, | |
new AppIdField(-1)) | |
lazy val client: ManyToOne[Client] = TestSchema.clientWithApplications.right(this) | |
lazy val proxyConfigs: OneToMany[ProxyConfig] = TestSchema.applicationWithProxyConfigs.left(this) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment