coldbox-modules / quick

A ColdBox ORM Engine
https://quick.ortusbooks.com
MIT License
23 stars 19 forks source link

regression in constrained relationship #202

Closed davidAtInleague closed 1 year ago

davidAtInleague commented 1 year ago

Ran into a regression running against commit (df4f626a30be3604c748c8bc9e1a691c3946c525). Now getting a "Quick couldn't figure out what to do with [addEagerConstraints]" error on a constrained relationship.

grammar is mssql

Repro:

component table="RMME_A" extends="quick.models.BaseEntity" accessors=true {
    property name="ID_A" type="numeric" sqltype="integer";

    variables._key = "ID_A";

    function B() {
    return hasMany(
            relationName = "RMME_B",
            foreignKey = "ID_A",
            localKey="ID_A"
        )
        .with( [ "C" ] ); // <<<<<< regression here; this now throws "Quick couldn't figure out what to do with [addEagerConstraints]"
    }
}

component table="RMME_B" extends="quick.models.BaseEntity" accessors=true {
    property name="ID_A" type="numeric" sqltype="integer";
    property name="ID_B" type="numeric" sqltype="integer";
    property name="ID_C" type="numeric" sqltype="integer";

    variables._key = "ID_B";

    function C() {
      return belongsTo( relationName = "RMME_C", foreignKey = "ID_C", localKey = "ID_C" );
    }
}

component table="RMME_C" extends="quick.models.BaseEntity" accessors=true {
    property name="ID_B" type="numeric" sqltype="integer";
    property name="ID_C" type="numeric" sqltype="integer";

    variables._key = "ID_C";
}

//
// tabledefs
//

CREATE TABLE [dbo].[RMME_A]([ID_A] [int] NULL, [ID_B] [int] NULL)
CREATE TABLE [dbo].[RMME_B]([ID_A] [int] NULL, [ID_B] [int] NULL, [ID_C] [int] NULL)
CREATE TABLE [dbo].[RMME_C]([ID_B] [int] NULL, [ID_C] [int] NULL)

INSERT INTO RMME_A (ID_A, ID_B)       VALUES (1,1);
INSERT INTO RMME_B (ID_A, ID_B, ID_C) VALUES (1,1,1);
INSERT INTO RMME_C (ID_B, ID_C)       VALUES (1,1);

//
// run it
//
getInstance("RMME_A").with("B").get();
elpete commented 1 year ago

Fixed in quick@5.2.2