Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: [Raku] Trying to get Red see the schema

by smokemachine (Hermit)
on Mar 28, 2021 at 14:29 UTC ( [id://11130511] : note . print w/replies, xml ) Need Help??

in reply to [Raku] Trying to get Red see the schema

Hi! Sorry, I was too late to answer that on #raku. The problem here is that when you create a `:model<Something>` Red tries to `use` "Something", on that case `Vmail` but that file does not exist, to fix that you could simply add `:require<Schema>` on that.
use Red; model User is table<_user> { has Int $!id is serial; has Str $.username is column is rw; has Str $.password is column{ :nullable } is rw; has @.vmails is relationship(*.user_id, :model<Vmail>, :requir +e<Schema>); } model Vmail { has Int $!id is serial; has Int $!user_id is referencing(*.id, :model<User>, :require< +Schema>); has Str $.name is column; has $.user is relationship(*.id, :model<User>, :require<Schema +>); }
I'm trying to make it not necessary.

Replies are listed 'Best First'.
Re^2: [Raku] Trying to get Red see the schema
by tomgracey (Scribe) on Mar 28, 2021 at 14:53 UTC

    Ah ok I see - thank you that is very helpful!

    I notice that you call your table _user (ie with an underscore). Is this because user is a reserved word in Postgres? Is there a way to actually have a table called user? I mean, in Postgres you would just have to make sure to double quote the word. Do you know if there's a way to switch on double quoting of table names?

      I'm just finishing my last change to make it possible to use any table name. It's going to wrap the table name with "". I'll let you know when it's committed.