From d45eeebaba9f44c8e0c8cbc9a921d334f6c8f627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Raddum=20Berg?= Date: Wed, 30 Aug 2023 12:26:15 +0200 Subject: [PATCH] Add constraints to table row comments --- sql/custom/constraints.sql | 1 - .../src/scala/scripts/GenHardcodedFiles.scala | 32 +++++++----- .../humanresources/employee/EmployeeRow.scala | 18 ++++--- .../EmployeedepartmenthistoryRow.scala | 6 ++- .../EmployeepayhistoryRow.scala | 6 ++- .../person/person/PersonRow.scala | 6 ++- .../billofmaterials/BillofmaterialsRow.scala | 20 ++++--- .../production/document/DocumentRow.scala | 3 +- .../production/location/LocationRow.scala | 6 ++- .../production/product/ProductRow.scala | 33 ++++++++---- .../ProductcosthistoryRow.scala | 9 ++-- .../ProductinventoryRow.scala | 3 +- .../ProductlistpricehistoryRow.scala | 9 ++-- .../productreview/ProductreviewRow.scala | 3 +- .../TransactionhistoryRow.scala | 3 +- .../TransactionhistoryarchiveRow.scala | 3 +- .../production/workorder/WorkorderRow.scala | 12 +++-- .../WorkorderroutingRow.scala | 21 +++++--- .../productvendor/ProductvendorRow.scala | 18 ++++--- .../PurchaseorderdetailRow.scala | 12 +++-- .../PurchaseorderheaderRow.scala | 18 ++++--- .../purchasing/shipmethod/ShipmethodRow.scala | 6 ++- .../purchasing/vendor/VendorRow.scala | 3 +- .../SalesorderdetailRow.scala | 9 ++-- .../SalesorderheaderRow.scala | 22 +++++--- .../sales/salesperson/SalespersonRow.scala | 15 ++++-- .../SalespersonquotahistoryRow.scala | 3 +- .../sales/salestaxrate/SalestaxrateRow.scala | 3 +- .../salesterritory/SalesterritoryRow.scala | 12 +++-- .../SalesterritoryhistoryRow.scala | 6 ++- .../ShoppingcartitemRow.scala | 3 +- .../sales/specialoffer/SpecialofferRow.scala | 15 ++++-- .../humanresources/employee/EmployeeRow.scala | 18 ++++--- .../EmployeedepartmenthistoryRow.scala | 6 ++- .../EmployeepayhistoryRow.scala | 6 ++- .../person/person/PersonRow.scala | 6 ++- .../billofmaterials/BillofmaterialsRow.scala | 20 ++++--- .../production/document/DocumentRow.scala | 3 +- .../production/location/LocationRow.scala | 6 ++- .../production/product/ProductRow.scala | 33 ++++++++---- .../ProductcosthistoryRow.scala | 9 ++-- .../ProductinventoryRow.scala | 3 +- .../ProductlistpricehistoryRow.scala | 9 ++-- .../productreview/ProductreviewRow.scala | 3 +- .../TransactionhistoryRow.scala | 3 +- .../TransactionhistoryarchiveRow.scala | 3 +- .../production/workorder/WorkorderRow.scala | 12 +++-- .../WorkorderroutingRow.scala | 21 +++++--- .../productvendor/ProductvendorRow.scala | 18 ++++--- .../PurchaseorderdetailRow.scala | 12 +++-- .../PurchaseorderheaderRow.scala | 18 ++++--- .../purchasing/shipmethod/ShipmethodRow.scala | 6 ++- .../purchasing/vendor/VendorRow.scala | 3 +- .../SalesorderdetailRow.scala | 9 ++-- .../SalesorderheaderRow.scala | 22 +++++--- .../sales/salesperson/SalespersonRow.scala | 15 ++++-- .../SalespersonquotahistoryRow.scala | 3 +- .../sales/salestaxrate/SalestaxrateRow.scala | 3 +- .../salesterritory/SalesterritoryRow.scala | 12 +++-- .../SalesterritoryhistoryRow.scala | 6 ++- .../ShoppingcartitemRow.scala | 3 +- .../sales/specialoffer/SpecialofferRow.scala | 15 ++++-- typo/src/scala/typo/MetaDb.scala | 52 ++++++++++++++----- typo/src/scala/typo/db.scala | 4 ++ .../scala/typo/internal/ComputedSqlFile.scala | 3 +- .../typo/internal/codegen/FilesRelation.scala | 5 +- 66 files changed, 476 insertions(+), 233 deletions(-) diff --git a/sql/custom/constraints.sql b/sql/custom/constraints.sql index ddaacae429..f334d94dee 100644 --- a/sql/custom/constraints.sql +++ b/sql/custom/constraints.sql @@ -21,7 +21,6 @@ from information_schema.table_constraints tc join pg_constraint pgc on pgc.conname = cc.constraint_name and pgc.connamespace = nsp.oid and pgc.contype = 'c' join cols col on col.table_schema = tc.table_schema and col.table_name = tc.table_name and col.ordinal_position = ANY (pgc.conkey) -where tc.constraint_schema not in ('pg_catalog', 'information_schema') group by tc.table_schema, tc.table_name, tc.constraint_name, diff --git a/typo-scripts/src/scala/scripts/GenHardcodedFiles.scala b/typo-scripts/src/scala/scripts/GenHardcodedFiles.scala index af71a0d063..e3f6fc634b 100644 --- a/typo-scripts/src/scala/scripts/GenHardcodedFiles.scala +++ b/typo-scripts/src/scala/scripts/GenHardcodedFiles.scala @@ -17,7 +17,7 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { val person = db.Table( name = db.RelationName(Some("myschema"), "person"), cols = NonEmptyList( - db.Col(db.ColName("id"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = Some("auto-increment"), None, DebugJson.Empty), + db.Col(db.ColName("id"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = Some("auto-increment"), None, Nil, DebugJson.Empty), db.Col( db.ColName("favourite_football_club_id"), db.Type.VarChar(Some(50)), @@ -25,14 +25,15 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { Nullability.NoNulls, columnDefault = None, None, + Nil, DebugJson.Empty ), - db.Col(db.ColName("name"), db.Type.VarChar(Some(100)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty), - db.Col(db.ColName("nick_name"), db.Type.VarChar(Some(30)), Some("varchar"), Nullability.Nullable, columnDefault = None, None, DebugJson.Empty), - db.Col(db.ColName("blog_url"), db.Type.VarChar(Some(100)), Some("varchar"), Nullability.Nullable, columnDefault = None, None, DebugJson.Empty), - db.Col(db.ColName("email"), db.Type.VarChar(Some(254)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty), - db.Col(db.ColName("phone"), db.Type.VarChar(Some(8)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty), - db.Col(db.ColName("likes_pizza"), db.Type.Boolean, Some("bool"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty), + db.Col(db.ColName("name"), db.Type.VarChar(Some(100)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty), + db.Col(db.ColName("nick_name"), db.Type.VarChar(Some(30)), Some("varchar"), Nullability.Nullable, columnDefault = None, None, Nil, DebugJson.Empty), + db.Col(db.ColName("blog_url"), db.Type.VarChar(Some(100)), Some("varchar"), Nullability.Nullable, columnDefault = None, None, Nil, DebugJson.Empty), + db.Col(db.ColName("email"), db.Type.VarChar(Some(254)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty), + db.Col(db.ColName("phone"), db.Type.VarChar(Some(8)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty), + db.Col(db.ColName("likes_pizza"), db.Type.Boolean, Some("bool"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty), db.Col( db.ColName("marital_status_id"), db.Type.VarChar(Some(50)), @@ -40,9 +41,10 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { Nullability.NoNulls, columnDefault = Some("some-value"), None, + Nil, DebugJson.Empty ), - db.Col(db.ColName("work_email"), db.Type.VarChar(Some(254)), Some("varchar"), Nullability.Nullable, columnDefault = None, None, DebugJson.Empty), + db.Col(db.ColName("work_email"), db.Type.VarChar(Some(254)), Some("varchar"), Nullability.Nullable, columnDefault = None, None, Nil, DebugJson.Empty), db.Col( db.ColName("sector"), db.Type.EnumRef(db.RelationName(Some("myschema"), "sector")), @@ -50,6 +52,7 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { Nullability.NoNulls, columnDefault = Some("PUBLIC"), None, + Nil, DebugJson.Empty ), db.Col( @@ -59,6 +62,7 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { Nullability.NoNulls, columnDefault = Some("one"), None, + Nil, DebugJson.Empty ) ), @@ -82,8 +86,8 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { val football_club = db.Table( name = db.RelationName(Some("myschema"), "football_club"), cols = NonEmptyList( - db.Col(db.ColName("id"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty), - db.Col(db.ColName("name"), db.Type.VarChar(Some(100)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty) + db.Col(db.ColName("id"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty), + db.Col(db.ColName("name"), db.Type.VarChar(Some(100)), Some("varchar"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty) ), Some(db.PrimaryKey(NonEmptyList(db.ColName("id")), db.RelationName(Some("myschema"), "football_club_pkey"))), Nil, @@ -92,7 +96,7 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { val marital_status = db.Table( name = db.RelationName(Some("myschema"), "marital_status"), cols = NonEmptyList( - db.Col(db.ColName("id"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = None, None, DebugJson.Empty) + db.Col(db.ColName("id"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = None, None, Nil, DebugJson.Empty) ), Some(db.PrimaryKey(NonEmptyList(db.ColName("id")), db.RelationName(Some("myschema"), "marital_status_pkey"))), Nil, @@ -102,9 +106,9 @@ object GenHardcodedFiles extends BleepCodegenScript("GenHardcodedFiles") { val cpk_person = db.Table( name = db.RelationName(Some("compositepk"), "person"), // name clash to ensure we handle it cols = NonEmptyList( - db.Col(db.ColName("one"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = Some("auto-increment"), None, DebugJson.Empty), - db.Col(db.ColName("two"), db.Type.Text, Some("text"), Nullability.Nullable, columnDefault = Some("auto-increment"), None, DebugJson.Empty), - db.Col(db.ColName("name"), db.Type.Text, Some("text"), Nullability.Nullable, columnDefault = None, None, DebugJson.Empty) + db.Col(db.ColName("one"), db.Type.Int8, Some("int8"), Nullability.NoNulls, columnDefault = Some("auto-increment"), None, Nil, DebugJson.Empty), + db.Col(db.ColName("two"), db.Type.Text, Some("text"), Nullability.Nullable, columnDefault = Some("auto-increment"), None, Nil, DebugJson.Empty), + db.Col(db.ColName("name"), db.Type.Text, Some("text"), Nullability.Nullable, columnDefault = None, None, Nil, DebugJson.Empty) ), Some(db.PrimaryKey(NonEmptyList(db.ColName("one"), db.ColName("two")), db.RelationName(Some("compositepk"), "person_pkey"))), Nil, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala index 1240a626b4..9b03144aa5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala @@ -35,19 +35,25 @@ case class EmployeeRow( loginid: /* max 256 chars */ String, /** Work title such as Buyer or Sales Representative. */ jobtitle: /* max 50 chars */ String, - /** Date of birth. */ + /** Date of birth. + Constraint CK_Employee_BirthDate affecting columns "birthdate": (((birthdate >= '1930-01-01'::date) AND (birthdate <= (now() - '18 years'::interval)))) */ birthdate: TypoLocalDate, - /** M = Married, S = Single */ + /** M = Married, S = Single + Constraint CK_Employee_MaritalStatus affecting columns "maritalstatus": ((upper((maritalstatus)::text) = ANY (ARRAY['M'::text, 'S'::text]))) */ maritalstatus: /* bpchar, max 1 chars */ String, - /** M = Male, F = Female */ + /** M = Male, F = Female + Constraint CK_Employee_Gender affecting columns "gender": ((upper((gender)::text) = ANY (ARRAY['M'::text, 'F'::text]))) */ gender: /* bpchar, max 1 chars */ String, - /** Employee hired on this date. */ + /** Employee hired on this date. + Constraint CK_Employee_HireDate affecting columns "hiredate": (((hiredate >= '1996-07-01'::date) AND (hiredate <= (now() + '1 day'::interval)))) */ hiredate: TypoLocalDate, /** Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. */ salariedflag: Flag, - /** Number of available vacation hours. */ + /** Number of available vacation hours. + Constraint CK_Employee_VacationHours affecting columns "vacationhours": (((vacationhours >= '-40'::integer) AND (vacationhours <= 240))) */ vacationhours: TypoShort, - /** Number of available sick leave hours. */ + /** Number of available sick leave hours. + Constraint CK_Employee_SickLeaveHours affecting columns "sickleavehours": (((sickleavehours >= 0) AND (sickleavehours <= 120))) */ sickleavehours: TypoShort, /** 0 = Inactive, 1 = Active */ currentflag: Flag, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala index 38be2466e9..5f20941e51 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala @@ -34,9 +34,11 @@ case class EmployeedepartmenthistoryRow( /** Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID. Points to [[shift.ShiftRow.shiftid]] */ shiftid: ShiftId, - /** Date the employee started work in the department. */ + /** Date the employee started work in the department. + Constraint CK_EmployeeDepartmentHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDate, - /** Date the employee left the department. NULL = Current department. */ + /** Date the employee left the department. NULL = Current department. + Constraint CK_EmployeeDepartmentHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDate], modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala index 9255359fa3..f727af67ad 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala @@ -28,9 +28,11 @@ case class EmployeepayhistoryRow( businessentityid: BusinessentityId, /** Date the change in pay is effective */ ratechangedate: TypoLocalDateTime, - /** Salary hourly rate. */ + /** Salary hourly rate. + Constraint CK_EmployeePayHistory_Rate affecting columns "rate": (((rate >= 6.50) AND (rate <= 200.00))) */ rate: BigDecimal, - /** 1 = Salary received monthly, 2 = Salary received biweekly */ + /** 1 = Salary received monthly, 2 = Salary received biweekly + Constraint CK_EmployeePayHistory_PayFrequency affecting columns "payfrequency": ((payfrequency = ANY (ARRAY[1, 2]))) */ payfrequency: TypoShort, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRow.scala index 3f8dec61be..a7f69e5c92 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRow.scala @@ -30,7 +30,8 @@ case class PersonRow( /** Primary key for Person records. Points to [[businessentity.BusinessentityRow.businessentityid]] */ businessentityid: BusinessentityId, - /** Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact */ + /** Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact + Constraint CK_Person_PersonType affecting columns "persontype": (((persontype IS NULL) OR (upper((persontype)::text) = ANY (ARRAY['SC'::text, 'VC'::text, 'IN'::text, 'EM'::text, 'SP'::text, 'GC'::text])))) */ persontype: /* bpchar, max 2 chars */ String, /** 0 = The data in FirstName and LastName are stored in western style (first name, last name) order. 1 = Eastern style (last name, first name) order. */ namestyle: NameStyle, @@ -44,7 +45,8 @@ case class PersonRow( lastname: Name, /** Surname suffix. For example, Sr. or Jr. */ suffix: Option[/* max 10 chars */ String], - /** 0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. */ + /** 0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. + Constraint CK_Person_EmailPromotion affecting columns "emailpromotion": (((emailpromotion >= 0) AND (emailpromotion <= 2))) */ emailpromotion: Int, /** Additional contact information about the person stored in xml format. */ additionalcontactinfo: Option[TypoXml], diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala index ca6610d40e..cf5228e8cb 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala @@ -27,21 +27,29 @@ case class BillofmaterialsRow( /** Primary key for BillOfMaterials records. */ billofmaterialsid: BillofmaterialsId, /** Parent product identification number. Foreign key to Product.ProductID. - Points to [[product.ProductRow.productid]] */ + Points to [[product.ProductRow.productid]] + Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) + Constraint CK_BillOfMaterials_ProductAssemblyID affecting columns "productassemblyid", "componentid": ((productassemblyid <> componentid)) */ productassemblyid: Option[ProductId], /** Component identification number. Foreign key to Product.ProductID. - Points to [[product.ProductRow.productid]] */ + Points to [[product.ProductRow.productid]] + Constraint CK_BillOfMaterials_ProductAssemblyID affecting columns "productassemblyid", "componentid": ((productassemblyid <> componentid)) */ componentid: ProductId, - /** Date the component started being used in the assembly item. */ + /** Date the component started being used in the assembly item. + Constraint CK_BillOfMaterials_EndDate affecting columns "enddate", "startdate": (((enddate > startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Date the component stopped being used in the assembly item. */ + /** Date the component stopped being used in the assembly item. + Constraint CK_BillOfMaterials_EndDate affecting columns "enddate", "startdate": (((enddate > startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], /** Standard code identifying the unit of measure for the quantity. Points to [[unitmeasure.UnitmeasureRow.unitmeasurecode]] */ unitmeasurecode: UnitmeasureId, - /** Indicates the depth the component is from its parent (AssemblyID). */ + /** Indicates the depth the component is from its parent (AssemblyID). + Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) */ bomlevel: TypoShort, - /** Quantity of the component needed to create the assembly. */ + /** Quantity of the component needed to create the assembly. + Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) + Constraint CK_BillOfMaterials_PerAssemblyQty affecting columns "perassemblyqty": ((perassemblyqty >= 1.00)) */ perassemblyqty: BigDecimal, modifieddate: TypoLocalDateTime ) diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala index 59b77717b9..775ccc6a03 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala @@ -40,7 +40,8 @@ case class DocumentRow( revision: /* bpchar, max 5 chars */ String, /** Engineering change approval number. */ changenumber: Int, - /** 1 = Pending approval, 2 = Approved, 3 = Obsolete */ + /** 1 = Pending approval, 2 = Approved, 3 = Obsolete + Constraint CK_Document_Status affecting columns "status": (((status >= 1) AND (status <= 3))) */ status: TypoShort, /** Document abstract. */ documentsummary: Option[String], diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRow.scala index 7f1875bb38..7519787340 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRow.scala @@ -26,9 +26,11 @@ case class LocationRow( locationid: LocationId, /** Location description. */ name: Name, - /** Standard hourly cost of the manufacturing location. */ + /** Standard hourly cost of the manufacturing location. + Constraint CK_Location_CostRate affecting columns "costrate": ((costrate >= 0.00)) */ costrate: BigDecimal, - /** Work capacity (in hours) of the manufacturing location. */ + /** Work capacity (in hours) of the manufacturing location. + Constraint CK_Location_Availability affecting columns "availability": ((availability >= 0.00)) */ availability: BigDecimal, modifieddate: TypoLocalDateTime ) diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRow.scala index d6ef9df69d..e7a9b5fff5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRow.scala @@ -40,13 +40,17 @@ case class ProductRow( finishedgoodsflag: Flag, /** Product color. */ color: Option[/* max 15 chars */ String], - /** Minimum inventory quantity. */ + /** Minimum inventory quantity. + Constraint CK_Product_SafetyStockLevel affecting columns "safetystocklevel": ((safetystocklevel > 0)) */ safetystocklevel: TypoShort, - /** Inventory level that triggers a purchase order or work order. */ + /** Inventory level that triggers a purchase order or work order. + Constraint CK_Product_ReorderPoint affecting columns "reorderpoint": ((reorderpoint > 0)) */ reorderpoint: TypoShort, - /** Standard cost of the product. */ + /** Standard cost of the product. + Constraint CK_Product_StandardCost affecting columns "standardcost": ((standardcost >= 0.00)) */ standardcost: BigDecimal, - /** Selling price. */ + /** Selling price. + Constraint CK_Product_ListPrice affecting columns "listprice": ((listprice >= 0.00)) */ listprice: BigDecimal, /** Product size. */ size: Option[/* max 5 chars */ String], @@ -56,15 +60,20 @@ case class ProductRow( /** Unit of measure for Weight column. Points to [[unitmeasure.UnitmeasureRow.unitmeasurecode]] */ weightunitmeasurecode: Option[UnitmeasureId], - /** Product weight. */ + /** Product weight. + Constraint CK_Product_Weight affecting columns "weight": ((weight > 0.00)) */ weight: Option[BigDecimal], - /** Number of days required to manufacture the product. */ + /** Number of days required to manufacture the product. + Constraint CK_Product_DaysToManufacture affecting columns "daystomanufacture": ((daystomanufacture >= 0)) */ daystomanufacture: Int, - /** R = Road, M = Mountain, T = Touring, S = Standard */ + /** R = Road, M = Mountain, T = Touring, S = Standard + Constraint CK_Product_ProductLine affecting columns "productline": (((upper((productline)::text) = ANY (ARRAY['S'::text, 'T'::text, 'M'::text, 'R'::text])) OR (productline IS NULL))) */ productline: Option[/* bpchar, max 2 chars */ String], - /** H = High, M = Medium, L = Low */ + /** H = High, M = Medium, L = Low + Constraint CK_Product_Class affecting columns "class": (((upper((class)::text) = ANY (ARRAY['L'::text, 'M'::text, 'H'::text])) OR (class IS NULL))) */ `class`: Option[/* bpchar, max 2 chars */ String], - /** W = Womens, M = Mens, U = Universal */ + /** W = Womens, M = Mens, U = Universal + Constraint CK_Product_Style affecting columns "style": (((upper((style)::text) = ANY (ARRAY['W'::text, 'M'::text, 'U'::text])) OR (style IS NULL))) */ style: Option[/* bpchar, max 2 chars */ String], /** Product is a member of this product subcategory. Foreign key to ProductSubCategory.ProductSubCategoryID. Points to [[productsubcategory.ProductsubcategoryRow.productsubcategoryid]] */ @@ -72,9 +81,11 @@ case class ProductRow( /** Product is a member of this product model. Foreign key to ProductModel.ProductModelID. Points to [[productmodel.ProductmodelRow.productmodelid]] */ productmodelid: Option[ProductmodelId], - /** Date the product was available for sale. */ + /** Date the product was available for sale. + Constraint CK_Product_SellEndDate affecting columns "sellenddate", "sellstartdate": (((sellenddate >= sellstartdate) OR (sellenddate IS NULL))) */ sellstartdate: TypoLocalDateTime, - /** Date the product was no longer available for sale. */ + /** Date the product was no longer available for sale. + Constraint CK_Product_SellEndDate affecting columns "sellenddate", "sellstartdate": (((sellenddate >= sellstartdate) OR (sellenddate IS NULL))) */ sellenddate: Option[TypoLocalDateTime], /** Date the product was discontinued. */ discontinueddate: Option[TypoLocalDateTime], diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala index 68ed345df7..c71a6df1ed 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala @@ -25,11 +25,14 @@ case class ProductcosthistoryRow( /** Product identification number. Foreign key to Product.ProductID Points to [[product.ProductRow.productid]] */ productid: ProductId, - /** Product cost start date. */ + /** Product cost start date. + Constraint CK_ProductCostHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Product cost end date. */ + /** Product cost end date. + Constraint CK_ProductCostHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], - /** Standard cost of the product. */ + /** Standard cost of the product. + Constraint CK_ProductCostHistory_StandardCost affecting columns "standardcost": ((standardcost >= 0.00)) */ standardcost: BigDecimal, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala index 68262771fa..1617364afd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala @@ -33,7 +33,8 @@ case class ProductinventoryRow( locationid: LocationId, /** Storage compartment within an inventory location. */ shelf: /* max 10 chars */ String, - /** Storage container on a shelf in an inventory location. */ + /** Storage container on a shelf in an inventory location. + Constraint CK_ProductInventory_Bin affecting columns "bin": (((bin >= 0) AND (bin <= 100))) */ bin: TypoShort, /** Quantity of products in the inventory location. */ quantity: TypoShort, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala index f924178285..f4b9036756 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala @@ -25,11 +25,14 @@ case class ProductlistpricehistoryRow( /** Product identification number. Foreign key to Product.ProductID Points to [[product.ProductRow.productid]] */ productid: ProductId, - /** List price start date. */ + /** List price start date. + Constraint CK_ProductListPriceHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** List price end date */ + /** List price end date + Constraint CK_ProductListPriceHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], - /** Product list price. */ + /** Product list price. + Constraint CK_ProductListPriceHistory_ListPrice affecting columns "listprice": ((listprice > 0.00)) */ listprice: BigDecimal, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala index 6633652e3a..3296042c13 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala @@ -34,7 +34,8 @@ case class ProductreviewRow( reviewdate: TypoLocalDateTime, /** Reviewer's e-mail address. */ emailaddress: /* max 50 chars */ String, - /** Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating. */ + /** Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating. + Constraint CK_ProductReview_Rating affecting columns "rating": (((rating >= 1) AND (rating <= 5))) */ rating: Int, /** Reviewer's comments */ comments: Option[/* max 3850 chars */ String], diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala index 0427f03bea..a95ff3e207 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala @@ -33,7 +33,8 @@ case class TransactionhistoryRow( referenceorderlineid: Int, /** Date and time of the transaction. */ transactiondate: TypoLocalDateTime, - /** W = WorkOrder, S = SalesOrder, P = PurchaseOrder */ + /** W = WorkOrder, S = SalesOrder, P = PurchaseOrder + Constraint CK_TransactionHistory_TransactionType affecting columns "transactiontype": ((upper((transactiontype)::text) = ANY (ARRAY['W'::text, 'S'::text, 'P'::text]))) */ transactiontype: /* bpchar, max 1 chars */ String, /** Product quantity. */ quantity: Int, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala index a7041b4a6e..38a7c85f4b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala @@ -31,7 +31,8 @@ case class TransactionhistoryarchiveRow( referenceorderlineid: Int, /** Date and time of the transaction. */ transactiondate: TypoLocalDateTime, - /** W = Work Order, S = Sales Order, P = Purchase Order */ + /** W = Work Order, S = Sales Order, P = Purchase Order + Constraint CK_TransactionHistoryArchive_TransactionType affecting columns "transactiontype": ((upper((transactiontype)::text) = ANY (ARRAY['W'::text, 'S'::text, 'P'::text]))) */ transactiontype: /* bpchar, max 1 chars */ String, /** Product quantity. */ quantity: Int, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala index 8e297c498f..b93befa08b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala @@ -29,13 +29,17 @@ case class WorkorderRow( /** Product identification number. Foreign key to Product.ProductID. Points to [[product.ProductRow.productid]] */ productid: ProductId, - /** Product quantity to build. */ + /** Product quantity to build. + Constraint CK_WorkOrder_OrderQty affecting columns "orderqty": ((orderqty > 0)) */ orderqty: Int, - /** Quantity that failed inspection. */ + /** Quantity that failed inspection. + Constraint CK_WorkOrder_ScrappedQty affecting columns "scrappedqty": ((scrappedqty >= 0)) */ scrappedqty: TypoShort, - /** Work order start date. */ + /** Work order start date. + Constraint CK_WorkOrder_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Work order end date. */ + /** Work order end date. + Constraint CK_WorkOrder_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], /** Work order due date. */ duedate: TypoLocalDateTime, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala index 7cf2a3fda5..313a9830ac 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala @@ -34,19 +34,26 @@ case class WorkorderroutingRow( /** Manufacturing location where the part is processed. Foreign key to Location.LocationID. Points to [[location.LocationRow.locationid]] */ locationid: LocationId, - /** Planned manufacturing start date. */ + /** Planned manufacturing start date. + Constraint CK_WorkOrderRouting_ScheduledEndDate affecting columns "scheduledenddate", "scheduledstartdate": ((scheduledenddate >= scheduledstartdate)) */ scheduledstartdate: TypoLocalDateTime, - /** Planned manufacturing end date. */ + /** Planned manufacturing end date. + Constraint CK_WorkOrderRouting_ScheduledEndDate affecting columns "scheduledenddate", "scheduledstartdate": ((scheduledenddate >= scheduledstartdate)) */ scheduledenddate: TypoLocalDateTime, - /** Actual start date. */ + /** Actual start date. + Constraint CK_WorkOrderRouting_ActualEndDate affecting columns "actualstartdate", "actualenddate": (((actualenddate >= actualstartdate) OR (actualenddate IS NULL) OR (actualstartdate IS NULL))) */ actualstartdate: Option[TypoLocalDateTime], - /** Actual end date. */ + /** Actual end date. + Constraint CK_WorkOrderRouting_ActualEndDate affecting columns "actualstartdate", "actualenddate": (((actualenddate >= actualstartdate) OR (actualenddate IS NULL) OR (actualstartdate IS NULL))) */ actualenddate: Option[TypoLocalDateTime], - /** Number of manufacturing hours used. */ + /** Number of manufacturing hours used. + Constraint CK_WorkOrderRouting_ActualResourceHrs affecting columns "actualresourcehrs": ((actualresourcehrs >= 0.0000)) */ actualresourcehrs: Option[BigDecimal], - /** Estimated manufacturing cost. */ + /** Estimated manufacturing cost. + Constraint CK_WorkOrderRouting_PlannedCost affecting columns "plannedcost": ((plannedcost > 0.00)) */ plannedcost: BigDecimal, - /** Actual manufacturing cost. */ + /** Actual manufacturing cost. + Constraint CK_WorkOrderRouting_ActualCost affecting columns "actualcost": ((actualcost > 0.00)) */ actualcost: Option[BigDecimal], modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala index eec0cc35e6..99a16fe24d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala @@ -30,19 +30,25 @@ case class ProductvendorRow( /** Primary key. Foreign key to Vendor.BusinessEntityID. Points to [[vendor.VendorRow.businessentityid]] */ businessentityid: BusinessentityId, - /** The average span of time (in days) between placing an order with the vendor and receiving the purchased product. */ + /** The average span of time (in days) between placing an order with the vendor and receiving the purchased product. + Constraint CK_ProductVendor_AverageLeadTime affecting columns "averageleadtime": ((averageleadtime >= 1)) */ averageleadtime: Int, - /** The vendor's usual selling price. */ + /** The vendor's usual selling price. + Constraint CK_ProductVendor_StandardPrice affecting columns "standardprice": ((standardprice > 0.00)) */ standardprice: BigDecimal, - /** The selling price when last purchased. */ + /** The selling price when last purchased. + Constraint CK_ProductVendor_LastReceiptCost affecting columns "lastreceiptcost": ((lastreceiptcost > 0.00)) */ lastreceiptcost: Option[BigDecimal], /** Date the product was last received by the vendor. */ lastreceiptdate: Option[TypoLocalDateTime], - /** The maximum quantity that should be ordered. */ + /** The maximum quantity that should be ordered. + Constraint CK_ProductVendor_MinOrderQty affecting columns "minorderqty": ((minorderqty >= 1)) */ minorderqty: Int, - /** The minimum quantity that should be ordered. */ + /** The minimum quantity that should be ordered. + Constraint CK_ProductVendor_MaxOrderQty affecting columns "maxorderqty": ((maxorderqty >= 1)) */ maxorderqty: Int, - /** The quantity currently on order. */ + /** The quantity currently on order. + Constraint CK_ProductVendor_OnOrderQty affecting columns "onorderqty": ((onorderqty >= 0)) */ onorderqty: Option[Int], /** The product's unit of measure. Points to [[production.unitmeasure.UnitmeasureRow.unitmeasurecode]] */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala index fb4c491020..2a0ed37355 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala @@ -31,16 +31,20 @@ case class PurchaseorderdetailRow( purchaseorderdetailid: Int, /** Date the product is expected to be received. */ duedate: TypoLocalDateTime, - /** Quantity ordered. */ + /** Quantity ordered. + Constraint CK_PurchaseOrderDetail_OrderQty affecting columns "orderqty": ((orderqty > 0)) */ orderqty: TypoShort, /** Product identification number. Foreign key to Product.ProductID. Points to [[production.product.ProductRow.productid]] */ productid: ProductId, - /** Vendor's selling price of a single product. */ + /** Vendor's selling price of a single product. + Constraint CK_PurchaseOrderDetail_UnitPrice affecting columns "unitprice": ((unitprice >= 0.00)) */ unitprice: BigDecimal, - /** Quantity actually received from the vendor. */ + /** Quantity actually received from the vendor. + Constraint CK_PurchaseOrderDetail_ReceivedQty affecting columns "receivedqty": ((receivedqty >= 0.00)) */ receivedqty: BigDecimal, - /** Quantity rejected during inspection. */ + /** Quantity rejected during inspection. + Constraint CK_PurchaseOrderDetail_RejectedQty affecting columns "rejectedqty": ((rejectedqty >= 0.00)) */ rejectedqty: BigDecimal, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala index e7a6360f87..291182fe6c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala @@ -28,7 +28,8 @@ case class PurchaseorderheaderRow( purchaseorderid: PurchaseorderheaderId, /** Incremental number to track changes to the purchase order over time. */ revisionnumber: TypoShort, - /** Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete */ + /** Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete + Constraint CK_PurchaseOrderHeader_Status affecting columns "status": (((status >= 1) AND (status <= 4))) */ status: TypoShort, /** Employee who created the purchase order. Foreign key to Employee.BusinessEntityID. Points to [[humanresources.employee.EmployeeRow.businessentityid]] */ @@ -39,15 +40,20 @@ case class PurchaseorderheaderRow( /** Shipping method. Foreign key to ShipMethod.ShipMethodID. Points to [[shipmethod.ShipmethodRow.shipmethodid]] */ shipmethodid: ShipmethodId, - /** Purchase order creation date. */ + /** Purchase order creation date. + Constraint CK_PurchaseOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ orderdate: TypoLocalDateTime, - /** Estimated shipment date from the vendor. */ + /** Estimated shipment date from the vendor. + Constraint CK_PurchaseOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ shipdate: Option[TypoLocalDateTime], - /** Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID. */ + /** Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID. + Constraint CK_PurchaseOrderHeader_SubTotal affecting columns "subtotal": ((subtotal >= 0.00)) */ subtotal: BigDecimal, - /** Tax amount. */ + /** Tax amount. + Constraint CK_PurchaseOrderHeader_TaxAmt affecting columns "taxamt": ((taxamt >= 0.00)) */ taxamt: BigDecimal, - /** Shipping cost. */ + /** Shipping cost. + Constraint CK_PurchaseOrderHeader_Freight affecting columns "freight": ((freight >= 0.00)) */ freight: BigDecimal, modifieddate: TypoLocalDateTime ) diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala index 9c54198c85..3adb541e05 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala @@ -27,9 +27,11 @@ case class ShipmethodRow( shipmethodid: ShipmethodId, /** Shipping company name. */ name: Name, - /** Minimum shipping charge. */ + /** Minimum shipping charge. + Constraint CK_ShipMethod_ShipBase affecting columns "shipbase": ((shipbase > 0.00)) */ shipbase: BigDecimal, - /** Shipping charge per pound. */ + /** Shipping charge per pound. + Constraint CK_ShipMethod_ShipRate affecting columns "shiprate": ((shiprate > 0.00)) */ shiprate: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala index 7178d45b7d..b8a9ed8b8d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala @@ -33,7 +33,8 @@ case class VendorRow( accountnumber: AccountNumber, /** Company name. */ name: Name, - /** 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average */ + /** 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average + Constraint CK_Vendor_CreditRating affecting columns "creditrating": (((creditrating >= 1) AND (creditrating <= 5))) */ creditrating: TypoShort, /** 0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product. */ preferredvendorstatus: Flag, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala index af4a064904..b55cef7565 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala @@ -33,7 +33,8 @@ case class SalesorderdetailRow( salesorderdetailid: Int, /** Shipment tracking number supplied by the shipper. */ carriertrackingnumber: Option[/* max 25 chars */ String], - /** Quantity ordered per product. */ + /** Quantity ordered per product. + Constraint CK_SalesOrderDetail_OrderQty affecting columns "orderqty": ((orderqty > 0)) */ orderqty: TypoShort, /** Product sold to customer. Foreign key to Product.ProductID. Points to [[specialofferproduct.SpecialofferproductRow.productid]] */ @@ -41,9 +42,11 @@ case class SalesorderdetailRow( /** Promotional code. Foreign key to SpecialOffer.SpecialOfferID. Points to [[specialofferproduct.SpecialofferproductRow.specialofferid]] */ specialofferid: SpecialofferId, - /** Selling price of a single product. */ + /** Selling price of a single product. + Constraint CK_SalesOrderDetail_UnitPrice affecting columns "unitprice": ((unitprice >= 0.00)) */ unitprice: BigDecimal, - /** Discount amount. */ + /** Discount amount. + Constraint CK_SalesOrderDetail_UnitPriceDiscount affecting columns "unitpricediscount": ((unitpricediscount >= 0.00)) */ unitpricediscount: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala index baa832e3a4..4eacb04a9d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala @@ -37,13 +37,18 @@ case class SalesorderheaderRow( salesorderid: SalesorderheaderId, /** Incremental number to track changes to the sales order over time. */ revisionnumber: TypoShort, - /** Dates the sales order was created. */ + /** Dates the sales order was created. + Constraint CK_SalesOrderHeader_DueDate affecting columns "orderdate", "duedate": ((duedate >= orderdate)) + Constraint CK_SalesOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ orderdate: TypoLocalDateTime, - /** Date the order is due to the customer. */ + /** Date the order is due to the customer. + Constraint CK_SalesOrderHeader_DueDate affecting columns "orderdate", "duedate": ((duedate >= orderdate)) */ duedate: TypoLocalDateTime, - /** Date the order was shipped to the customer. */ + /** Date the order was shipped to the customer. + Constraint CK_SalesOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ shipdate: Option[TypoLocalDateTime], - /** Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled */ + /** Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled + Constraint CK_SalesOrderHeader_Status affecting columns "status": (((status >= 0) AND (status <= 8))) */ status: TypoShort, /** 0 = Order placed by sales person. 1 = Order placed online by customer. */ onlineorderflag: Flag, @@ -77,11 +82,14 @@ case class SalesorderheaderRow( /** Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. Points to [[currencyrate.CurrencyrateRow.currencyrateid]] */ currencyrateid: Option[CurrencyrateId], - /** Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. */ + /** Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. + Constraint CK_SalesOrderHeader_SubTotal affecting columns "subtotal": ((subtotal >= 0.00)) */ subtotal: BigDecimal, - /** Tax amount. */ + /** Tax amount. + Constraint CK_SalesOrderHeader_TaxAmt affecting columns "taxamt": ((taxamt >= 0.00)) */ taxamt: BigDecimal, - /** Shipping cost. */ + /** Shipping cost. + Constraint CK_SalesOrderHeader_Freight affecting columns "freight": ((freight >= 0.00)) */ freight: BigDecimal, /** Total due from customer. Computed as Subtotal + TaxAmt + Freight. */ totaldue: Option[BigDecimal], diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala index 22a3d1840a..34baecefa8 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala @@ -30,15 +30,20 @@ case class SalespersonRow( /** Territory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID. Points to [[salesterritory.SalesterritoryRow.territoryid]] */ territoryid: Option[SalesterritoryId], - /** Projected yearly sales. */ + /** Projected yearly sales. + Constraint CK_SalesPerson_SalesQuota affecting columns "salesquota": ((salesquota > 0.00)) */ salesquota: Option[BigDecimal], - /** Bonus due if quota is met. */ + /** Bonus due if quota is met. + Constraint CK_SalesPerson_Bonus affecting columns "bonus": ((bonus >= 0.00)) */ bonus: BigDecimal, - /** Commision percent received per sale. */ + /** Commision percent received per sale. + Constraint CK_SalesPerson_CommissionPct affecting columns "commissionpct": ((commissionpct >= 0.00)) */ commissionpct: BigDecimal, - /** Sales total year to date. */ + /** Sales total year to date. + Constraint CK_SalesPerson_SalesYTD affecting columns "salesytd": ((salesytd >= 0.00)) */ salesytd: BigDecimal, - /** Sales total of previous year. */ + /** Sales total of previous year. + Constraint CK_SalesPerson_SalesLastYear affecting columns "saleslastyear": ((saleslastyear >= 0.00)) */ saleslastyear: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala index 525a3b1d75..ed0864e6ac 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala @@ -28,7 +28,8 @@ case class SalespersonquotahistoryRow( businessentityid: BusinessentityId, /** Sales quota date. */ quotadate: TypoLocalDateTime, - /** Sales quota amount. */ + /** Sales quota amount. + Constraint CK_SalesPersonQuotaHistory_SalesQuota affecting columns "salesquota": ((salesquota > 0.00)) */ salesquota: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala index f5684be9f1..eecea7809c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala @@ -30,7 +30,8 @@ case class SalestaxrateRow( /** State, province, or country/region the sales tax applies to. Points to [[person.stateprovince.StateprovinceRow.stateprovinceid]] */ stateprovinceid: StateprovinceId, - /** 1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions. */ + /** 1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions. + Constraint CK_SalesTaxRate_TaxType affecting columns "taxtype": (((taxtype >= 1) AND (taxtype <= 3))) */ taxtype: TypoShort, /** Tax rate amount. */ taxrate: BigDecimal, diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala index ab2b687af3..109bebea0b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala @@ -33,13 +33,17 @@ case class SalesterritoryRow( countryregioncode: CountryregionId, /** Geographic area to which the sales territory belong. */ group: /* max 50 chars */ String, - /** Sales in the territory year to date. */ + /** Sales in the territory year to date. + Constraint CK_SalesTerritory_SalesYTD affecting columns "salesytd": ((salesytd >= 0.00)) */ salesytd: BigDecimal, - /** Sales in the territory the previous year. */ + /** Sales in the territory the previous year. + Constraint CK_SalesTerritory_SalesLastYear affecting columns "saleslastyear": ((saleslastyear >= 0.00)) */ saleslastyear: BigDecimal, - /** Business costs in the territory year to date. */ + /** Business costs in the territory year to date. + Constraint CK_SalesTerritory_CostYTD affecting columns "costytd": ((costytd >= 0.00)) */ costytd: BigDecimal, - /** Business costs in the territory the previous year. */ + /** Business costs in the territory the previous year. + Constraint CK_SalesTerritory_CostLastYear affecting columns "costlastyear": ((costlastyear >= 0.00)) */ costlastyear: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala index cf7d9c955e..df60d25c23 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala @@ -30,9 +30,11 @@ case class SalesterritoryhistoryRow( /** Primary key. Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID. Points to [[salesterritory.SalesterritoryRow.territoryid]] */ territoryid: SalesterritoryId, - /** Primary key. Date the sales representive started work in the territory. */ + /** Primary key. Date the sales representive started work in the territory. + Constraint CK_SalesTerritoryHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Date the sales representative left work in the territory. */ + /** Date the sales representative left work in the territory. + Constraint CK_SalesTerritoryHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala index 3f23682e7c..77cfdf0686 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala @@ -26,7 +26,8 @@ case class ShoppingcartitemRow( shoppingcartitemid: ShoppingcartitemId, /** Shopping cart identification number. */ shoppingcartid: /* max 50 chars */ String, - /** Product quantity ordered. */ + /** Product quantity ordered. + Constraint CK_ShoppingCartItem_Quantity affecting columns "quantity": ((quantity >= 1)) */ quantity: Int, /** Product ordered. Foreign key to Product.ProductID. Points to [[production.product.ProductRow.productid]] */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala index 8e83a56172..73d6666bd6 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala @@ -26,19 +26,24 @@ case class SpecialofferRow( specialofferid: SpecialofferId, /** Discount description. */ description: /* max 255 chars */ String, - /** Discount precentage. */ + /** Discount precentage. + Constraint CK_SpecialOffer_DiscountPct affecting columns "discountpct": ((discountpct >= 0.00)) */ discountpct: BigDecimal, /** Discount type category. */ `type`: /* max 50 chars */ String, /** Group the discount applies to such as Reseller or Customer. */ category: /* max 50 chars */ String, - /** Discount start date. */ + /** Discount start date. + Constraint CK_SpecialOffer_EndDate affecting columns "startdate", "enddate": ((enddate >= startdate)) */ startdate: TypoLocalDateTime, - /** Discount end date. */ + /** Discount end date. + Constraint CK_SpecialOffer_EndDate affecting columns "startdate", "enddate": ((enddate >= startdate)) */ enddate: TypoLocalDateTime, - /** Minimum discount percent allowed. */ + /** Minimum discount percent allowed. + Constraint CK_SpecialOffer_MinQty affecting columns "minqty": ((minqty >= 0)) */ minqty: Int, - /** Maximum discount percent allowed. */ + /** Maximum discount percent allowed. + Constraint CK_SpecialOffer_MaxQty affecting columns "maxqty": ((maxqty >= 0)) */ maxqty: Option[Int], rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala index e32896b95c..d425204638 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRow.scala @@ -30,19 +30,25 @@ case class EmployeeRow( loginid: /* max 256 chars */ String, /** Work title such as Buyer or Sales Representative. */ jobtitle: /* max 50 chars */ String, - /** Date of birth. */ + /** Date of birth. + Constraint CK_Employee_BirthDate affecting columns "birthdate": (((birthdate >= '1930-01-01'::date) AND (birthdate <= (now() - '18 years'::interval)))) */ birthdate: TypoLocalDate, - /** M = Married, S = Single */ + /** M = Married, S = Single + Constraint CK_Employee_MaritalStatus affecting columns "maritalstatus": ((upper((maritalstatus)::text) = ANY (ARRAY['M'::text, 'S'::text]))) */ maritalstatus: /* bpchar, max 1 chars */ String, - /** M = Male, F = Female */ + /** M = Male, F = Female + Constraint CK_Employee_Gender affecting columns "gender": ((upper((gender)::text) = ANY (ARRAY['M'::text, 'F'::text]))) */ gender: /* bpchar, max 1 chars */ String, - /** Employee hired on this date. */ + /** Employee hired on this date. + Constraint CK_Employee_HireDate affecting columns "hiredate": (((hiredate >= '1996-07-01'::date) AND (hiredate <= (now() + '1 day'::interval)))) */ hiredate: TypoLocalDate, /** Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. */ salariedflag: Flag, - /** Number of available vacation hours. */ + /** Number of available vacation hours. + Constraint CK_Employee_VacationHours affecting columns "vacationhours": (((vacationhours >= '-40'::integer) AND (vacationhours <= 240))) */ vacationhours: TypoShort, - /** Number of available sick leave hours. */ + /** Number of available sick leave hours. + Constraint CK_Employee_SickLeaveHours affecting columns "sickleavehours": (((sickleavehours >= 0) AND (sickleavehours <= 120))) */ sickleavehours: TypoShort, /** 0 = Inactive, 1 = Active */ currentflag: Flag, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala index f79500528e..d1052ea384 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRow.scala @@ -28,9 +28,11 @@ case class EmployeedepartmenthistoryRow( /** Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID. Points to [[shift.ShiftRow.shiftid]] */ shiftid: ShiftId, - /** Date the employee started work in the department. */ + /** Date the employee started work in the department. + Constraint CK_EmployeeDepartmentHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDate, - /** Date the employee left the department. NULL = Current department. */ + /** Date the employee left the department. NULL = Current department. + Constraint CK_EmployeeDepartmentHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDate], modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala index 37f5bbfd55..08d652302f 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRow.scala @@ -23,9 +23,11 @@ case class EmployeepayhistoryRow( businessentityid: BusinessentityId, /** Date the change in pay is effective */ ratechangedate: TypoLocalDateTime, - /** Salary hourly rate. */ + /** Salary hourly rate. + Constraint CK_EmployeePayHistory_Rate affecting columns "rate": (((rate >= 6.50) AND (rate <= 200.00))) */ rate: BigDecimal, - /** 1 = Salary received monthly, 2 = Salary received biweekly */ + /** 1 = Salary received monthly, 2 = Salary received biweekly + Constraint CK_EmployeePayHistory_PayFrequency affecting columns "payfrequency": ((payfrequency = ANY (ARRAY[1, 2]))) */ payfrequency: TypoShort, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/person/person/PersonRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/person/person/PersonRow.scala index 963d2db86b..ebf95b3013 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/person/person/PersonRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/person/person/PersonRow.scala @@ -25,7 +25,8 @@ case class PersonRow( /** Primary key for Person records. Points to [[businessentity.BusinessentityRow.businessentityid]] */ businessentityid: BusinessentityId, - /** Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact */ + /** Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact + Constraint CK_Person_PersonType affecting columns "persontype": (((persontype IS NULL) OR (upper((persontype)::text) = ANY (ARRAY['SC'::text, 'VC'::text, 'IN'::text, 'EM'::text, 'SP'::text, 'GC'::text])))) */ persontype: /* bpchar, max 2 chars */ String, /** 0 = The data in FirstName and LastName are stored in western style (first name, last name) order. 1 = Eastern style (last name, first name) order. */ namestyle: NameStyle, @@ -39,7 +40,8 @@ case class PersonRow( lastname: Name, /** Surname suffix. For example, Sr. or Jr. */ suffix: Option[/* max 10 chars */ String], - /** 0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. */ + /** 0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. + Constraint CK_Person_EmailPromotion affecting columns "emailpromotion": (((emailpromotion >= 0) AND (emailpromotion <= 2))) */ emailpromotion: Int, /** Additional contact information about the person stored in xml format. */ additionalcontactinfo: Option[TypoXml], diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala index 7cd2d16eca..421172f50f 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRow.scala @@ -22,21 +22,29 @@ case class BillofmaterialsRow( /** Primary key for BillOfMaterials records. */ billofmaterialsid: BillofmaterialsId, /** Parent product identification number. Foreign key to Product.ProductID. - Points to [[product.ProductRow.productid]] */ + Points to [[product.ProductRow.productid]] + Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) + Constraint CK_BillOfMaterials_ProductAssemblyID affecting columns "productassemblyid", "componentid": ((productassemblyid <> componentid)) */ productassemblyid: Option[ProductId], /** Component identification number. Foreign key to Product.ProductID. - Points to [[product.ProductRow.productid]] */ + Points to [[product.ProductRow.productid]] + Constraint CK_BillOfMaterials_ProductAssemblyID affecting columns "productassemblyid", "componentid": ((productassemblyid <> componentid)) */ componentid: ProductId, - /** Date the component started being used in the assembly item. */ + /** Date the component started being used in the assembly item. + Constraint CK_BillOfMaterials_EndDate affecting columns "enddate", "startdate": (((enddate > startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Date the component stopped being used in the assembly item. */ + /** Date the component stopped being used in the assembly item. + Constraint CK_BillOfMaterials_EndDate affecting columns "enddate", "startdate": (((enddate > startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], /** Standard code identifying the unit of measure for the quantity. Points to [[unitmeasure.UnitmeasureRow.unitmeasurecode]] */ unitmeasurecode: UnitmeasureId, - /** Indicates the depth the component is from its parent (AssemblyID). */ + /** Indicates the depth the component is from its parent (AssemblyID). + Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) */ bomlevel: TypoShort, - /** Quantity of the component needed to create the assembly. */ + /** Quantity of the component needed to create the assembly. + Constraint CK_BillOfMaterials_BOMLevel affecting columns "bomlevel", "productassemblyid", "perassemblyqty": ((((productassemblyid IS NULL) AND (bomlevel = 0) AND (perassemblyqty = 1.00)) OR ((productassemblyid IS NOT NULL) AND (bomlevel >= 1)))) + Constraint CK_BillOfMaterials_PerAssemblyQty affecting columns "perassemblyqty": ((perassemblyqty >= 1.00)) */ perassemblyqty: BigDecimal, modifieddate: TypoLocalDateTime ) diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala index 857674c511..2138a4cf5c 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRow.scala @@ -35,7 +35,8 @@ case class DocumentRow( revision: /* bpchar, max 5 chars */ String, /** Engineering change approval number. */ changenumber: Int, - /** 1 = Pending approval, 2 = Approved, 3 = Obsolete */ + /** 1 = Pending approval, 2 = Approved, 3 = Obsolete + Constraint CK_Document_Status affecting columns "status": (((status >= 1) AND (status <= 3))) */ status: TypoShort, /** Document abstract. */ documentsummary: Option[String], diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/location/LocationRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/location/LocationRow.scala index a2ee7883b7..4a3c160213 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/location/LocationRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/location/LocationRow.scala @@ -21,9 +21,11 @@ case class LocationRow( locationid: LocationId, /** Location description. */ name: Name, - /** Standard hourly cost of the manufacturing location. */ + /** Standard hourly cost of the manufacturing location. + Constraint CK_Location_CostRate affecting columns "costrate": ((costrate >= 0.00)) */ costrate: BigDecimal, - /** Work capacity (in hours) of the manufacturing location. */ + /** Work capacity (in hours) of the manufacturing location. + Constraint CK_Location_Availability affecting columns "availability": ((availability >= 0.00)) */ availability: BigDecimal, modifieddate: TypoLocalDateTime ) diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/product/ProductRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/product/ProductRow.scala index 5ee1223e14..89bf415179 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/product/ProductRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/product/ProductRow.scala @@ -39,13 +39,17 @@ case class ProductRow( finishedgoodsflag: Flag, /** Product color. */ color: Option[/* max 15 chars */ String], - /** Minimum inventory quantity. */ + /** Minimum inventory quantity. + Constraint CK_Product_SafetyStockLevel affecting columns "safetystocklevel": ((safetystocklevel > 0)) */ safetystocklevel: TypoShort, - /** Inventory level that triggers a purchase order or work order. */ + /** Inventory level that triggers a purchase order or work order. + Constraint CK_Product_ReorderPoint affecting columns "reorderpoint": ((reorderpoint > 0)) */ reorderpoint: TypoShort, - /** Standard cost of the product. */ + /** Standard cost of the product. + Constraint CK_Product_StandardCost affecting columns "standardcost": ((standardcost >= 0.00)) */ standardcost: BigDecimal, - /** Selling price. */ + /** Selling price. + Constraint CK_Product_ListPrice affecting columns "listprice": ((listprice >= 0.00)) */ listprice: BigDecimal, /** Product size. */ size: Option[/* max 5 chars */ String], @@ -55,15 +59,20 @@ case class ProductRow( /** Unit of measure for Weight column. Points to [[unitmeasure.UnitmeasureRow.unitmeasurecode]] */ weightunitmeasurecode: Option[UnitmeasureId], - /** Product weight. */ + /** Product weight. + Constraint CK_Product_Weight affecting columns "weight": ((weight > 0.00)) */ weight: Option[BigDecimal], - /** Number of days required to manufacture the product. */ + /** Number of days required to manufacture the product. + Constraint CK_Product_DaysToManufacture affecting columns "daystomanufacture": ((daystomanufacture >= 0)) */ daystomanufacture: Int, - /** R = Road, M = Mountain, T = Touring, S = Standard */ + /** R = Road, M = Mountain, T = Touring, S = Standard + Constraint CK_Product_ProductLine affecting columns "productline": (((upper((productline)::text) = ANY (ARRAY['S'::text, 'T'::text, 'M'::text, 'R'::text])) OR (productline IS NULL))) */ productline: Option[/* bpchar, max 2 chars */ String], - /** H = High, M = Medium, L = Low */ + /** H = High, M = Medium, L = Low + Constraint CK_Product_Class affecting columns "class": (((upper((class)::text) = ANY (ARRAY['L'::text, 'M'::text, 'H'::text])) OR (class IS NULL))) */ `class`: Option[/* bpchar, max 2 chars */ String], - /** W = Womens, M = Mens, U = Universal */ + /** W = Womens, M = Mens, U = Universal + Constraint CK_Product_Style affecting columns "style": (((upper((style)::text) = ANY (ARRAY['W'::text, 'M'::text, 'U'::text])) OR (style IS NULL))) */ style: Option[/* bpchar, max 2 chars */ String], /** Product is a member of this product subcategory. Foreign key to ProductSubCategory.ProductSubCategoryID. Points to [[productsubcategory.ProductsubcategoryRow.productsubcategoryid]] */ @@ -71,9 +80,11 @@ case class ProductRow( /** Product is a member of this product model. Foreign key to ProductModel.ProductModelID. Points to [[productmodel.ProductmodelRow.productmodelid]] */ productmodelid: Option[ProductmodelId], - /** Date the product was available for sale. */ + /** Date the product was available for sale. + Constraint CK_Product_SellEndDate affecting columns "sellenddate", "sellstartdate": (((sellenddate >= sellstartdate) OR (sellenddate IS NULL))) */ sellstartdate: TypoLocalDateTime, - /** Date the product was no longer available for sale. */ + /** Date the product was no longer available for sale. + Constraint CK_Product_SellEndDate affecting columns "sellenddate", "sellstartdate": (((sellenddate >= sellstartdate) OR (sellenddate IS NULL))) */ sellenddate: Option[TypoLocalDateTime], /** Date the product was discontinued. */ discontinueddate: Option[TypoLocalDateTime], diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala index e658de590a..a1f34def15 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRow.scala @@ -20,11 +20,14 @@ case class ProductcosthistoryRow( /** Product identification number. Foreign key to Product.ProductID Points to [[product.ProductRow.productid]] */ productid: ProductId, - /** Product cost start date. */ + /** Product cost start date. + Constraint CK_ProductCostHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Product cost end date. */ + /** Product cost end date. + Constraint CK_ProductCostHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], - /** Standard cost of the product. */ + /** Standard cost of the product. + Constraint CK_ProductCostHistory_StandardCost affecting columns "standardcost": ((standardcost >= 0.00)) */ standardcost: BigDecimal, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala index 5cb0597350..3cff612a6d 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRow.scala @@ -28,7 +28,8 @@ case class ProductinventoryRow( locationid: LocationId, /** Storage compartment within an inventory location. */ shelf: /* max 10 chars */ String, - /** Storage container on a shelf in an inventory location. */ + /** Storage container on a shelf in an inventory location. + Constraint CK_ProductInventory_Bin affecting columns "bin": (((bin >= 0) AND (bin <= 100))) */ bin: TypoShort, /** Quantity of products in the inventory location. */ quantity: TypoShort, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala index 10df830a36..bc2b5d3ab7 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRow.scala @@ -20,11 +20,14 @@ case class ProductlistpricehistoryRow( /** Product identification number. Foreign key to Product.ProductID Points to [[product.ProductRow.productid]] */ productid: ProductId, - /** List price start date. */ + /** List price start date. + Constraint CK_ProductListPriceHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** List price end date */ + /** List price end date + Constraint CK_ProductListPriceHistory_EndDate affecting columns "enddate", "startdate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], - /** Product list price. */ + /** Product list price. + Constraint CK_ProductListPriceHistory_ListPrice affecting columns "listprice": ((listprice > 0.00)) */ listprice: BigDecimal, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala index 9abad5c82e..33bfe4ae30 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRow.scala @@ -29,7 +29,8 @@ case class ProductreviewRow( reviewdate: TypoLocalDateTime, /** Reviewer's e-mail address. */ emailaddress: /* max 50 chars */ String, - /** Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating. */ + /** Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating. + Constraint CK_ProductReview_Rating affecting columns "rating": (((rating >= 1) AND (rating <= 5))) */ rating: Int, /** Reviewer's comments */ comments: Option[/* max 3850 chars */ String], diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala index d23e6c4f55..102e407d0e 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRow.scala @@ -28,7 +28,8 @@ case class TransactionhistoryRow( referenceorderlineid: Int, /** Date and time of the transaction. */ transactiondate: TypoLocalDateTime, - /** W = WorkOrder, S = SalesOrder, P = PurchaseOrder */ + /** W = WorkOrder, S = SalesOrder, P = PurchaseOrder + Constraint CK_TransactionHistory_TransactionType affecting columns "transactiontype": ((upper((transactiontype)::text) = ANY (ARRAY['W'::text, 'S'::text, 'P'::text]))) */ transactiontype: /* bpchar, max 1 chars */ String, /** Product quantity. */ quantity: Int, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala index 5ae0d2ac84..5cf5dc0f04 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRow.scala @@ -26,7 +26,8 @@ case class TransactionhistoryarchiveRow( referenceorderlineid: Int, /** Date and time of the transaction. */ transactiondate: TypoLocalDateTime, - /** W = Work Order, S = Sales Order, P = Purchase Order */ + /** W = Work Order, S = Sales Order, P = Purchase Order + Constraint CK_TransactionHistoryArchive_TransactionType affecting columns "transactiontype": ((upper((transactiontype)::text) = ANY (ARRAY['W'::text, 'S'::text, 'P'::text]))) */ transactiontype: /* bpchar, max 1 chars */ String, /** Product quantity. */ quantity: Int, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala index a1a8ee640c..ed942faa03 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorder/WorkorderRow.scala @@ -24,13 +24,17 @@ case class WorkorderRow( /** Product identification number. Foreign key to Product.ProductID. Points to [[product.ProductRow.productid]] */ productid: ProductId, - /** Product quantity to build. */ + /** Product quantity to build. + Constraint CK_WorkOrder_OrderQty affecting columns "orderqty": ((orderqty > 0)) */ orderqty: Int, - /** Quantity that failed inspection. */ + /** Quantity that failed inspection. + Constraint CK_WorkOrder_ScrappedQty affecting columns "scrappedqty": ((scrappedqty >= 0)) */ scrappedqty: TypoShort, - /** Work order start date. */ + /** Work order start date. + Constraint CK_WorkOrder_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Work order end date. */ + /** Work order end date. + Constraint CK_WorkOrder_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], /** Work order due date. */ duedate: TypoLocalDateTime, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala index 6160ed2c6a..b7f7c7f261 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRow.scala @@ -29,19 +29,26 @@ case class WorkorderroutingRow( /** Manufacturing location where the part is processed. Foreign key to Location.LocationID. Points to [[location.LocationRow.locationid]] */ locationid: LocationId, - /** Planned manufacturing start date. */ + /** Planned manufacturing start date. + Constraint CK_WorkOrderRouting_ScheduledEndDate affecting columns "scheduledenddate", "scheduledstartdate": ((scheduledenddate >= scheduledstartdate)) */ scheduledstartdate: TypoLocalDateTime, - /** Planned manufacturing end date. */ + /** Planned manufacturing end date. + Constraint CK_WorkOrderRouting_ScheduledEndDate affecting columns "scheduledenddate", "scheduledstartdate": ((scheduledenddate >= scheduledstartdate)) */ scheduledenddate: TypoLocalDateTime, - /** Actual start date. */ + /** Actual start date. + Constraint CK_WorkOrderRouting_ActualEndDate affecting columns "actualstartdate", "actualenddate": (((actualenddate >= actualstartdate) OR (actualenddate IS NULL) OR (actualstartdate IS NULL))) */ actualstartdate: Option[TypoLocalDateTime], - /** Actual end date. */ + /** Actual end date. + Constraint CK_WorkOrderRouting_ActualEndDate affecting columns "actualstartdate", "actualenddate": (((actualenddate >= actualstartdate) OR (actualenddate IS NULL) OR (actualstartdate IS NULL))) */ actualenddate: Option[TypoLocalDateTime], - /** Number of manufacturing hours used. */ + /** Number of manufacturing hours used. + Constraint CK_WorkOrderRouting_ActualResourceHrs affecting columns "actualresourcehrs": ((actualresourcehrs >= 0.0000)) */ actualresourcehrs: Option[BigDecimal], - /** Estimated manufacturing cost. */ + /** Estimated manufacturing cost. + Constraint CK_WorkOrderRouting_PlannedCost affecting columns "plannedcost": ((plannedcost > 0.00)) */ plannedcost: BigDecimal, - /** Actual manufacturing cost. */ + /** Actual manufacturing cost. + Constraint CK_WorkOrderRouting_ActualCost affecting columns "actualcost": ((actualcost > 0.00)) */ actualcost: Option[BigDecimal], modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala index e547b239d6..00e0b75ac1 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRow.scala @@ -25,19 +25,25 @@ case class ProductvendorRow( /** Primary key. Foreign key to Vendor.BusinessEntityID. Points to [[vendor.VendorRow.businessentityid]] */ businessentityid: BusinessentityId, - /** The average span of time (in days) between placing an order with the vendor and receiving the purchased product. */ + /** The average span of time (in days) between placing an order with the vendor and receiving the purchased product. + Constraint CK_ProductVendor_AverageLeadTime affecting columns "averageleadtime": ((averageleadtime >= 1)) */ averageleadtime: Int, - /** The vendor's usual selling price. */ + /** The vendor's usual selling price. + Constraint CK_ProductVendor_StandardPrice affecting columns "standardprice": ((standardprice > 0.00)) */ standardprice: BigDecimal, - /** The selling price when last purchased. */ + /** The selling price when last purchased. + Constraint CK_ProductVendor_LastReceiptCost affecting columns "lastreceiptcost": ((lastreceiptcost > 0.00)) */ lastreceiptcost: Option[BigDecimal], /** Date the product was last received by the vendor. */ lastreceiptdate: Option[TypoLocalDateTime], - /** The maximum quantity that should be ordered. */ + /** The maximum quantity that should be ordered. + Constraint CK_ProductVendor_MinOrderQty affecting columns "minorderqty": ((minorderqty >= 1)) */ minorderqty: Int, - /** The minimum quantity that should be ordered. */ + /** The minimum quantity that should be ordered. + Constraint CK_ProductVendor_MaxOrderQty affecting columns "maxorderqty": ((maxorderqty >= 1)) */ maxorderqty: Int, - /** The quantity currently on order. */ + /** The quantity currently on order. + Constraint CK_ProductVendor_OnOrderQty affecting columns "onorderqty": ((onorderqty >= 0)) */ onorderqty: Option[Int], /** The product's unit of measure. Points to [[production.unitmeasure.UnitmeasureRow.unitmeasurecode]] */ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala index dce3a09314..cef4791ae9 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRow.scala @@ -26,16 +26,20 @@ case class PurchaseorderdetailRow( purchaseorderdetailid: Int, /** Date the product is expected to be received. */ duedate: TypoLocalDateTime, - /** Quantity ordered. */ + /** Quantity ordered. + Constraint CK_PurchaseOrderDetail_OrderQty affecting columns "orderqty": ((orderqty > 0)) */ orderqty: TypoShort, /** Product identification number. Foreign key to Product.ProductID. Points to [[production.product.ProductRow.productid]] */ productid: ProductId, - /** Vendor's selling price of a single product. */ + /** Vendor's selling price of a single product. + Constraint CK_PurchaseOrderDetail_UnitPrice affecting columns "unitprice": ((unitprice >= 0.00)) */ unitprice: BigDecimal, - /** Quantity actually received from the vendor. */ + /** Quantity actually received from the vendor. + Constraint CK_PurchaseOrderDetail_ReceivedQty affecting columns "receivedqty": ((receivedqty >= 0.00)) */ receivedqty: BigDecimal, - /** Quantity rejected during inspection. */ + /** Quantity rejected during inspection. + Constraint CK_PurchaseOrderDetail_RejectedQty affecting columns "rejectedqty": ((rejectedqty >= 0.00)) */ rejectedqty: BigDecimal, modifieddate: TypoLocalDateTime ){ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala index 447c0a89ce..b36930d77f 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRow.scala @@ -23,7 +23,8 @@ case class PurchaseorderheaderRow( purchaseorderid: PurchaseorderheaderId, /** Incremental number to track changes to the purchase order over time. */ revisionnumber: TypoShort, - /** Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete */ + /** Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete + Constraint CK_PurchaseOrderHeader_Status affecting columns "status": (((status >= 1) AND (status <= 4))) */ status: TypoShort, /** Employee who created the purchase order. Foreign key to Employee.BusinessEntityID. Points to [[humanresources.employee.EmployeeRow.businessentityid]] */ @@ -34,15 +35,20 @@ case class PurchaseorderheaderRow( /** Shipping method. Foreign key to ShipMethod.ShipMethodID. Points to [[shipmethod.ShipmethodRow.shipmethodid]] */ shipmethodid: ShipmethodId, - /** Purchase order creation date. */ + /** Purchase order creation date. + Constraint CK_PurchaseOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ orderdate: TypoLocalDateTime, - /** Estimated shipment date from the vendor. */ + /** Estimated shipment date from the vendor. + Constraint CK_PurchaseOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ shipdate: Option[TypoLocalDateTime], - /** Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID. */ + /** Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID. + Constraint CK_PurchaseOrderHeader_SubTotal affecting columns "subtotal": ((subtotal >= 0.00)) */ subtotal: BigDecimal, - /** Tax amount. */ + /** Tax amount. + Constraint CK_PurchaseOrderHeader_TaxAmt affecting columns "taxamt": ((taxamt >= 0.00)) */ taxamt: BigDecimal, - /** Shipping cost. */ + /** Shipping cost. + Constraint CK_PurchaseOrderHeader_Freight affecting columns "freight": ((freight >= 0.00)) */ freight: BigDecimal, modifieddate: TypoLocalDateTime ) diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala index 2b349ea3cb..5623bba170 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRow.scala @@ -22,9 +22,11 @@ case class ShipmethodRow( shipmethodid: ShipmethodId, /** Shipping company name. */ name: Name, - /** Minimum shipping charge. */ + /** Minimum shipping charge. + Constraint CK_ShipMethod_ShipBase affecting columns "shipbase": ((shipbase > 0.00)) */ shipbase: BigDecimal, - /** Shipping charge per pound. */ + /** Shipping charge per pound. + Constraint CK_ShipMethod_ShipRate affecting columns "shiprate": ((shiprate > 0.00)) */ shiprate: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala index 2aee23a6af..f22929781b 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRow.scala @@ -28,7 +28,8 @@ case class VendorRow( accountnumber: AccountNumber, /** Company name. */ name: Name, - /** 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average */ + /** 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average + Constraint CK_Vendor_CreditRating affecting columns "creditrating": (((creditrating >= 1) AND (creditrating <= 5))) */ creditrating: TypoShort, /** 0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product. */ preferredvendorstatus: Flag, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala index 577d75a2da..c0ac2a64de 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRow.scala @@ -28,7 +28,8 @@ case class SalesorderdetailRow( salesorderdetailid: Int, /** Shipment tracking number supplied by the shipper. */ carriertrackingnumber: Option[/* max 25 chars */ String], - /** Quantity ordered per product. */ + /** Quantity ordered per product. + Constraint CK_SalesOrderDetail_OrderQty affecting columns "orderqty": ((orderqty > 0)) */ orderqty: TypoShort, /** Product sold to customer. Foreign key to Product.ProductID. Points to [[specialofferproduct.SpecialofferproductRow.productid]] */ @@ -36,9 +37,11 @@ case class SalesorderdetailRow( /** Promotional code. Foreign key to SpecialOffer.SpecialOfferID. Points to [[specialofferproduct.SpecialofferproductRow.specialofferid]] */ specialofferid: SpecialofferId, - /** Selling price of a single product. */ + /** Selling price of a single product. + Constraint CK_SalesOrderDetail_UnitPrice affecting columns "unitprice": ((unitprice >= 0.00)) */ unitprice: BigDecimal, - /** Discount amount. */ + /** Discount amount. + Constraint CK_SalesOrderDetail_UnitPriceDiscount affecting columns "unitpricediscount": ((unitpricediscount >= 0.00)) */ unitpricediscount: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala index b68e2a4e7e..e5c5c1e5ea 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRow.scala @@ -36,13 +36,18 @@ case class SalesorderheaderRow( salesorderid: SalesorderheaderId, /** Incremental number to track changes to the sales order over time. */ revisionnumber: TypoShort, - /** Dates the sales order was created. */ + /** Dates the sales order was created. + Constraint CK_SalesOrderHeader_DueDate affecting columns "orderdate", "duedate": ((duedate >= orderdate)) + Constraint CK_SalesOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ orderdate: TypoLocalDateTime, - /** Date the order is due to the customer. */ + /** Date the order is due to the customer. + Constraint CK_SalesOrderHeader_DueDate affecting columns "orderdate", "duedate": ((duedate >= orderdate)) */ duedate: TypoLocalDateTime, - /** Date the order was shipped to the customer. */ + /** Date the order was shipped to the customer. + Constraint CK_SalesOrderHeader_ShipDate affecting columns "orderdate", "shipdate": (((shipdate >= orderdate) OR (shipdate IS NULL))) */ shipdate: Option[TypoLocalDateTime], - /** Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled */ + /** Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled + Constraint CK_SalesOrderHeader_Status affecting columns "status": (((status >= 0) AND (status <= 8))) */ status: TypoShort, /** 0 = Order placed by sales person. 1 = Order placed online by customer. */ onlineorderflag: Flag, @@ -76,11 +81,14 @@ case class SalesorderheaderRow( /** Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. Points to [[currencyrate.CurrencyrateRow.currencyrateid]] */ currencyrateid: Option[CurrencyrateId], - /** Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. */ + /** Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. + Constraint CK_SalesOrderHeader_SubTotal affecting columns "subtotal": ((subtotal >= 0.00)) */ subtotal: BigDecimal, - /** Tax amount. */ + /** Tax amount. + Constraint CK_SalesOrderHeader_TaxAmt affecting columns "taxamt": ((taxamt >= 0.00)) */ taxamt: BigDecimal, - /** Shipping cost. */ + /** Shipping cost. + Constraint CK_SalesOrderHeader_Freight affecting columns "freight": ((freight >= 0.00)) */ freight: BigDecimal, /** Total due from customer. Computed as Subtotal + TaxAmt + Freight. */ totaldue: Option[BigDecimal], diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala index b998c0483e..18f25a4920 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRow.scala @@ -25,15 +25,20 @@ case class SalespersonRow( /** Territory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID. Points to [[salesterritory.SalesterritoryRow.territoryid]] */ territoryid: Option[SalesterritoryId], - /** Projected yearly sales. */ + /** Projected yearly sales. + Constraint CK_SalesPerson_SalesQuota affecting columns "salesquota": ((salesquota > 0.00)) */ salesquota: Option[BigDecimal], - /** Bonus due if quota is met. */ + /** Bonus due if quota is met. + Constraint CK_SalesPerson_Bonus affecting columns "bonus": ((bonus >= 0.00)) */ bonus: BigDecimal, - /** Commision percent received per sale. */ + /** Commision percent received per sale. + Constraint CK_SalesPerson_CommissionPct affecting columns "commissionpct": ((commissionpct >= 0.00)) */ commissionpct: BigDecimal, - /** Sales total year to date. */ + /** Sales total year to date. + Constraint CK_SalesPerson_SalesYTD affecting columns "salesytd": ((salesytd >= 0.00)) */ salesytd: BigDecimal, - /** Sales total of previous year. */ + /** Sales total of previous year. + Constraint CK_SalesPerson_SalesLastYear affecting columns "saleslastyear": ((saleslastyear >= 0.00)) */ saleslastyear: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala index 68579349a1..bfb7c2c7b2 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRow.scala @@ -23,7 +23,8 @@ case class SalespersonquotahistoryRow( businessentityid: BusinessentityId, /** Sales quota date. */ quotadate: TypoLocalDateTime, - /** Sales quota amount. */ + /** Sales quota amount. + Constraint CK_SalesPersonQuotaHistory_SalesQuota affecting columns "salesquota": ((salesquota > 0.00)) */ salesquota: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala index 1fff261577..45d1a9a66e 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRow.scala @@ -25,7 +25,8 @@ case class SalestaxrateRow( /** State, province, or country/region the sales tax applies to. Points to [[person.stateprovince.StateprovinceRow.stateprovinceid]] */ stateprovinceid: StateprovinceId, - /** 1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions. */ + /** 1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions. + Constraint CK_SalesTaxRate_TaxType affecting columns "taxtype": (((taxtype >= 1) AND (taxtype <= 3))) */ taxtype: TypoShort, /** Tax rate amount. */ taxrate: BigDecimal, diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala index 85d000c4b1..d76f8c2007 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRow.scala @@ -28,13 +28,17 @@ case class SalesterritoryRow( countryregioncode: CountryregionId, /** Geographic area to which the sales territory belong. */ group: /* max 50 chars */ String, - /** Sales in the territory year to date. */ + /** Sales in the territory year to date. + Constraint CK_SalesTerritory_SalesYTD affecting columns "salesytd": ((salesytd >= 0.00)) */ salesytd: BigDecimal, - /** Sales in the territory the previous year. */ + /** Sales in the territory the previous year. + Constraint CK_SalesTerritory_SalesLastYear affecting columns "saleslastyear": ((saleslastyear >= 0.00)) */ saleslastyear: BigDecimal, - /** Business costs in the territory year to date. */ + /** Business costs in the territory year to date. + Constraint CK_SalesTerritory_CostYTD affecting columns "costytd": ((costytd >= 0.00)) */ costytd: BigDecimal, - /** Business costs in the territory the previous year. */ + /** Business costs in the territory the previous year. + Constraint CK_SalesTerritory_CostLastYear affecting columns "costlastyear": ((costlastyear >= 0.00)) */ costlastyear: BigDecimal, rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala index 7f56a4871f..dc1467df97 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRow.scala @@ -24,9 +24,11 @@ case class SalesterritoryhistoryRow( /** Primary key. Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID. Points to [[salesterritory.SalesterritoryRow.territoryid]] */ territoryid: SalesterritoryId, - /** Primary key. Date the sales representive started work in the territory. */ + /** Primary key. Date the sales representive started work in the territory. + Constraint CK_SalesTerritoryHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ startdate: TypoLocalDateTime, - /** Date the sales representative left work in the territory. */ + /** Date the sales representative left work in the territory. + Constraint CK_SalesTerritoryHistory_EndDate affecting columns "startdate", "enddate": (((enddate >= startdate) OR (enddate IS NULL))) */ enddate: Option[TypoLocalDateTime], rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala index 1093ca7733..2e1284bfd4 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRow.scala @@ -21,7 +21,8 @@ case class ShoppingcartitemRow( shoppingcartitemid: ShoppingcartitemId, /** Shopping cart identification number. */ shoppingcartid: /* max 50 chars */ String, - /** Product quantity ordered. */ + /** Product quantity ordered. + Constraint CK_ShoppingCartItem_Quantity affecting columns "quantity": ((quantity >= 1)) */ quantity: Int, /** Product ordered. Foreign key to Product.ProductID. Points to [[production.product.ProductRow.productid]] */ diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala index d1cedfb65b..be6a936521 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRow.scala @@ -21,19 +21,24 @@ case class SpecialofferRow( specialofferid: SpecialofferId, /** Discount description. */ description: /* max 255 chars */ String, - /** Discount precentage. */ + /** Discount precentage. + Constraint CK_SpecialOffer_DiscountPct affecting columns "discountpct": ((discountpct >= 0.00)) */ discountpct: BigDecimal, /** Discount type category. */ `type`: /* max 50 chars */ String, /** Group the discount applies to such as Reseller or Customer. */ category: /* max 50 chars */ String, - /** Discount start date. */ + /** Discount start date. + Constraint CK_SpecialOffer_EndDate affecting columns "startdate", "enddate": ((enddate >= startdate)) */ startdate: TypoLocalDateTime, - /** Discount end date. */ + /** Discount end date. + Constraint CK_SpecialOffer_EndDate affecting columns "startdate", "enddate": ((enddate >= startdate)) */ enddate: TypoLocalDateTime, - /** Minimum discount percent allowed. */ + /** Minimum discount percent allowed. + Constraint CK_SpecialOffer_MinQty affecting columns "minqty": ((minqty >= 0)) */ minqty: Int, - /** Maximum discount percent allowed. */ + /** Maximum discount percent allowed. + Constraint CK_SpecialOffer_MaxQty affecting columns "maxqty": ((maxqty >= 0)) */ maxqty: Option[Int], rowguid: UUID, modifieddate: TypoLocalDateTime diff --git a/typo/src/scala/typo/MetaDb.scala b/typo/src/scala/typo/MetaDb.scala index 291799c6c4..c055803fa3 100644 --- a/typo/src/scala/typo/MetaDb.scala +++ b/typo/src/scala/typo/MetaDb.scala @@ -1,6 +1,7 @@ package typo import typo.generated.custom.comments.{CommentsSqlRepoImpl, CommentsSqlRow} +import typo.generated.custom.constraints.{ConstraintsSqlRepoImpl, ConstraintsSqlRow} import typo.generated.custom.domains.{DomainsSqlRepoImpl, DomainsSqlRow} import typo.generated.custom.enums.{EnumsSqlRepoImpl, EnumsSqlRow} import typo.generated.custom.view_find_all.* @@ -32,7 +33,8 @@ object MetaDb { columns: List[ColumnsViewRow], views: List[ViewFindAllSqlRow], domains: List[DomainsSqlRow], - columnComments: List[CommentsSqlRow] + columnComments: List[CommentsSqlRow], + constraints: List[ConstraintsSqlRow] ) object Input { @@ -54,7 +56,8 @@ object MetaDb { columns = timed("columns")(ColumnsViewRepoImpl.selectAll), views = timed("views")(ViewFindAllSqlRepoImpl()), domains = timed("domains")(DomainsSqlRepoImpl()), - columnComments = timed("columnComments")(CommentsSqlRepoImpl()) + columnComments = timed("columnComments")(CommentsSqlRepoImpl()), + constraints = timed("constraints")(ConstraintsSqlRepoImpl()) ) } } @@ -87,6 +90,15 @@ object MetaDb { ) } + val constraints: Map[(db.RelationName, db.ColName), List[db.Constraint]] = + input.constraints + .collect { case ConstraintsSqlRow(tableSchema, Some(tableName), Some(columns), Some(constraintName), Some(checkClause)) => + columns.map(column => (db.RelationName(tableSchema, tableName), db.ColName(column)) -> db.Constraint(constraintName, columns.map(db.ColName.apply).toList, checkClause)) + } + .flatten + .groupBy { case (k, _) => k } + .map { case (k, rows) => (k, rows.map { case (_, c) => c }.sortBy(_.name)) } + val typeMapperDb = TypeMapperDb(enums, domains) val comments: Map[(db.RelationName, db.ColName), String] = @@ -127,14 +139,16 @@ object MetaDb { db.Type.Text } + val coord = (relationName, mdCol.name) val dbCol = db.Col( name = mdCol.name, tpe = dbType, udtName = None, columnDefault = None, - comment = comments.get((relationName, mdCol.name)), + comment = comments.get(coord), jsonDescription = DebugJson(mdCol), - nullability = nullability + nullability = nullability, + constraints = constraints.getOrElse(coord, Nil) ) (dbCol, mdCol.parsedColumnName) } @@ -153,6 +167,14 @@ object MetaDb { if (views.contains(relationName)) None else { val columns = columnsByTable(relationName).sortBy(_.ordinalPosition) + val fks: List[db.ForeignKey] = foreignKeys.getOrElse(relationName, List.empty) + + val deps: Map[db.ColName, (db.RelationName, db.ColName)] = + fks.flatMap { fk => + val otherTable: db.RelationName = fk.otherTable + val value = fk.otherCols.map(cn => (otherTable, cn)) + fk.cols.zip(value).toList + }.toMap val mappedCols: List[db.Col] = columns.map { c => @@ -170,26 +192,30 @@ object MetaDb { System.err.println(s"Couldn't translate type from relation ${relationName.value} column ${colName.value} with type ${colName.value}. Falling back to text") db.Type.Text } + val coord = (relationName, colName) db.Col( name = colName, columnDefault = c.columnDefault, nullability = nullability, tpe = tpe, udtName = c.udtName, - comment = comments.get((relationName, colName)), - jsonDescription = jsonDescription + comment = comments.get(coord), + jsonDescription = jsonDescription, + constraints = constraints.getOrElse(coord, Nil) ++ deps.get(colName).flatMap(otherCoord => constraints.get(otherCoord)).getOrElse(Nil) ) } for { mappedCols <- NonEmptyList.fromList(mappedCols) - } yield db.Table( - name = relationName, - cols = mappedCols, - primaryKey = primaryKeys.get(relationName), - uniqueKeys = uniqueKeys.getOrElse(relationName, List.empty), - foreignKeys = foreignKeys.getOrElse(relationName, List.empty) - ) + } yield { + db.Table( + name = relationName, + cols = mappedCols, + primaryKey = primaryKeys.get(relationName), + uniqueKeys = uniqueKeys.getOrElse(relationName, List.empty), + foreignKeys = fks + ) + } } } diff --git a/typo/src/scala/typo/db.scala b/typo/src/scala/typo/db.scala index e397cd5db8..5a3dba36a0 100644 --- a/typo/src/scala/typo/db.scala +++ b/typo/src/scala/typo/db.scala @@ -67,6 +67,9 @@ object db { case class Domain(name: RelationName, tpe: Type, isNotNull: Nullability, hasDefault: Boolean, constraintDefinition: Option[String]) case class StringEnum(name: RelationName, values: List[String]) case class ColName(value: String) extends AnyVal + + case class Constraint(name: String, columns: List[ColName], checkClause: String) + case class Col( name: ColName, tpe: Type, @@ -74,6 +77,7 @@ object db { nullability: Nullability, columnDefault: Option[String], comment: Option[String], + constraints: List[Constraint], jsonDescription: DebugJson ) case class RelationName(schema: Option[String], name: String) { diff --git a/typo/src/scala/typo/internal/ComputedSqlFile.scala b/typo/src/scala/typo/internal/ComputedSqlFile.scala index 1e4e29ed49..6b4a5ad687 100644 --- a/typo/src/scala/typo/internal/ComputedSqlFile.scala +++ b/typo/src/scala/typo/internal/ComputedSqlFile.scala @@ -63,7 +63,8 @@ case class ComputedSqlFile( columnDefault = None, comment = None, jsonDescription = DebugJson(col), - nullability = nullability + nullability = nullability, + constraints = Nil ) ) } diff --git a/typo/src/scala/typo/internal/codegen/FilesRelation.scala b/typo/src/scala/typo/internal/codegen/FilesRelation.scala index 7157200d57..1d309f2cb0 100644 --- a/typo/src/scala/typo/internal/codegen/FilesRelation.scala +++ b/typo/src/scala/typo/internal/codegen/FilesRelation.scala @@ -15,12 +15,13 @@ case class FilesRelation(naming: Naming, names: ComputedNames, maybeCols: Option } val formattedCols = cols.map { col => - val commentPieces = List( + val commentPieces = List[Iterable[String]]( col.dbCol.comment, - col.pointsTo map { case (relationName, columnName) => + col.pointsTo.map { case (relationName, columnName) => val shortened = sc.QIdent(dropCommonPrefix(naming.rowName(relationName).idents, names.RowName.value.idents)) s"Points to [[${sc.renderTree(shortened)}.${naming.field(columnName).value}]]" }, + col.dbCol.constraints.map(c => s"Constraint ${c.name} affecting columns ${c.columns.map(_.code.render.asString).mkString(", ")}: ${c.checkClause}"), if (options.debugTypes) col.dbCol.jsonDescription.maybeJson.map(other => s"debug: ${Json.stringify(other)}") else None