Red icon indicating copy to clipboard operation
Red copied to clipboard

Create a way for `has-one` relationship use `.create` (created after #472)

Open FCO opened this issue 4 years ago • 6 comments

take a look at #472

FCO avatar Mar 21 '21 22:03 FCO

The interesting part of it is that it is actually possible set attribute type to the model it is refers to. I.e.: ... Foo.attr.WHICH # MyModel

@vrurg but on that case, Foo.attr should return a Red::Column to make it possible to be used inside .map, .grep, etc...

FCO avatar May 04 '21 13:05 FCO

As @jonathanstowe have said on the original issue, I think returning a model type would be the best way, it could use the .join-on (the same method we use to find joins) to create it with the right external ids... I'll give it a try as soon as possible!

If we do that change, should that generate a new API version?

FCO avatar Nov 04 '21 20:11 FCO

I don't think it needs a different API version, because Empty is false, a type object is false.

jonathanstowe avatar Nov 04 '21 20:11 jonathanstowe

I'm still trying to figure out why... but my change is working if I define the referencing's model as type and does not work if I define it as string:

image

FCO avatar Nov 06 '21 15:11 FCO

for now: https://github.com/FCO/Red/pull/523

FCO avatar Nov 06 '21 16:11 FCO

There are still some bugs on it... but it seems to be mostly working...

FCO avatar Nov 09 '21 08:11 FCO