Skip to content

Commit

Permalink
Fix rendering logic for primary key (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
springwiz authored Oct 7, 2020
1 parent 9b46729 commit 20fa66e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions internal/arrai/bindata.go

Large diffs are not rendered by default.

Binary file modified pkg/importer/avro/transformer_cli.arraiz
Binary file not shown.
Binary file modified pkg/importer/spanner/import_migrations.arraiz
Binary file not shown.
Binary file modified pkg/importer/spanner/import_spanner_sql.arraiz
Binary file not shown.
2 changes: 1 addition & 1 deletion pkg/importer/spanner/sysl.arrai
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let attributePatterns = \entity \attr
$`${k}="${v}"`,
};
let pk = cond {
(entity.primary_key where //seq.contains(attr.name, .@item)):
entity.primary_key where attr.name = //seq.split("(", .@item rank (:.@))(0):
$`~pk${cond {sortingOrder(entity, attr):$`, ~${sortingOrder(entity, attr) ::}`}}`
};
let fk = cond { matchingFKs(entity, attr): '~fk' };
Expand Down
1 change: 1 addition & 0 deletions pkg/importer/spanner/tests/spanner.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CREATE INDEX InterleaveIndex ON Customer (AccountNum, CustomerID) INTERLEAVE IN

CREATE TABLE CustomerHasAccount (
CustomerID STRING(36) NOT NULL,
Customer STRING(36) NOT NULL,
AccountNum STRING(23) NOT NULL,
LegalRole STRING(10) NOT NULL,
BranchID STRING(6) NOT NULL,
Expand Down
1 change: 1 addition & 0 deletions pkg/importer/spanner/tests/spanner.sysl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ customeraccounts [spanner_spec="1.0", package="com.example.package"]:

!table CustomerHasAccount [primary_key="AccountNum(asc),CustomerID", foreign_keys=[["columns:CustomerID"],["constraint:FK_AccountNum","columns:AccountNum,BranchID"]]]:
CustomerID <: Customer.CustomerID [~pk, ~fk]
Customer <: string(36)
AccountNum <: Account.AccountNum [~pk, ~asc, ~fk]
LegalRole <: string(10)
BranchID <: Account.BSB [~fk]
Expand Down

0 comments on commit 20fa66e

Please sign in to comment.