Skip to content

Commit

Permalink
test kotlin-orm#405 for postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Jan 22, 2023
1 parent 49d8493 commit 5912e05
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,23 @@ class CommonTest : BasePostgreSqlTest() {
.first()
assertThat(mood1, equalTo(null))
}

interface TestMultiGeneratedKey : Entity<TestMultiGeneratedKey> {
var id: Int
var k: String
var v: String
}

object TestMultiGeneratedKeys : Table<TestMultiGeneratedKey>("t_multi_generated_key") {
val id = int("id").primaryKey().bindTo { it.id }
val k = varchar("k").bindTo { it.k }
val v = varchar("v").bindTo { it.v }
}

@Test
fun testMultiGeneratedKey() {
val e = Entity.create<TestMultiGeneratedKey>()
e.v = "test~~"
database.sequenceOf(TestMultiGeneratedKeys).add(e)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
drop table if exists t_department;
drop table if exists t_employee;
drop table if exists t_multi_generated_key;
drop table if exists t_metadata;
drop table if exists t_enum;
drop type if exists mood;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
create extension if not exists hstore;
create extension if not exists earthdistance cascade;
create extension if not exists "uuid-ossp";

create table t_department(
id serial primary key,
Expand All @@ -18,6 +19,12 @@ create table t_employee(
department_id int not null
);

create table t_multi_generated_key(
id serial primary key,
k varchar(128) not null default uuid_generate_v4(),
v varchar(128)
);

create table t_metadata(
id serial primary key,
attrs hstore,
Expand Down

0 comments on commit 5912e05

Please sign in to comment.