question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reference primary keys are not using the imported type

See original GitHub issue

Here, the primary key on bar references the primary key on foo

CREATE TABLE foo (id uuid primary key);
CREATE TABLE bar (id uuid primary key references foo(id));

Foo.ts

export type FooId = string & { __flavor?: 'foo' }; ;

export default interface Foo {
  /** Primary key. Index: foo_pkey */
  id: FooId;
}

export interface FooInitializer {
  /** Primary key. Index: foo_pkey */
  id: FooId;
}

export const tableName = 'foo'

Bar.ts

import { FooId } from './Foo';

export type BarId = string & { __flavor?: 'bar' };

export default interface Bar {
  /** Primary key. Index: bar_pkey */
  id: BarId;
}

export interface BarInitializer {
  /** Primary key. Index: bar_pkey */
  id: BarId;
}

Notice how FooId is imported, but is not actually used, which causes the typescript compiler to complain.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kristiandupontcommented, Jan 19, 2021

Ah you are right, I was a bit too quick there. Thank you for the explanation. I will try fixing this hopefully soonish 😃

1reaction
Scott-Allen-Mind-Gyncommented, Oct 8, 2021

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Primary Key problems when importing - sql - Stack Overflow
I am running into a problem where duplicate keys are found which gives error on import. Specifically, release # "49221" is the value...
Read more >
Add Only on an import definition requires a primary key?
The functionality of "Add Only" import type is to add new records. For instance your DE contains 4 records already and now you...
Read more >
Primary and Foreign Key Constraints - SQL Server
Primary keys and foreign keys are two types of constraints that can be used to enforce data integrity in SQL Server tables.
Read more >
Foreign Key Constraint | CockroachDB Docs
Foreign key columns must use their referenced column's type. ... Using IMPORT INTO will invalidate foreign keys without a VALIDATE CONSTRAINT statement.
Read more >
SQL Foreign key - SQLShack
To create a SQL foreign key constraint, the parent table should have primary key column or column with UNIQUE constraint.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found