oyvindberg / typo

Typed Postgresql integration for Scala. Hopes to avoid typos
https://oyvindberg.github.io/typo/
MIT License
99 stars 9 forks source link

Improve type flow #89

Closed oyvindberg closed 4 months ago

oyvindberg commented 4 months ago

example:

create table flaff
(
    code            short_text  not null,
    another_code    varchar(20) not null,
    some_number     integer     not null,
    specifier       short_text  not null,
    parentSpecifier short_text,
    constraint flaff_pk primary key (code, another_code, some_number, specifier),
    constraint flaff_parent_fk foreign key (code, another_code, some_number, parentSpecifier) references flaff
);

case class FlaffRow(
  /** Points to [[FlaffRow.code]] */
  code: ShortText,
  /** Points to [[FlaffRow.anotherCode]] */
  anotherCode: /* max 20 chars */ String,
  /** Points to [[FlaffRow.someNumber]] */
  someNumber: Int,
  specifier: ShortText,
  /** Points to [[FlaffRow.specifier]] */
  parentspecifier: Option[ShortText]
){
   val compositeId: FlaffId = FlaffId(code, anotherCode, someNumber, specifier)
 }