2

I'm using sails v1.2.2 with sails-postgresql adapter. Looking for using Model with specific schemaName. But relation with mapped with default schemaName (public)

{
   tableName : "t_role",
   meta: {
     schemaName: 'autorisation'
   }
}

AdapterError: Unexpected error from database adapter: relation "public.t_role" does not exist

johnabrams7
  • 399
  • 2
  • 10

1 Answers1

1

Hi there i'm facing the same issue when i try to upgrade to sails v1.x.x. I Try To figure it out all day long do some debug *thx for VSCode.

ps: i dont know if this approach really solve the problem, but it works

i have to add some code in two files of waterline library here are some files

  1. forge-stage-three-query.js

    i dont know how exactly the waterline works but sails will add/replace(if existing) meta attributes if u want to fetch data when you query the model add some fetch in meta properties

So Ihave to add some code like this in line 82

s3Q.using = model.tableName;

if (typeof model.meta.schemaName !== 'undefined'){
  //meta property only set if query fetch : true
  if (typeof s3Q.meta !== 'undefined'){
    //we have to initialize propery of meta
    s3Q.meta.schemaName = model.meta.schemaName;
  }else{
    s3Q.meta = model.meta;
  }
}

And everythings works perfectly until i try to get some data with populate, and sails get crash the schema is set to public again, after i'm doing some debug again i found this file

  1. help-find.js

in this file i need to replace some code

at line 247 replace to this code

meta: junctionTableModel.meta,

at line 290 and 441 replace to this code

var meta = childTableModel.meta;

Hope this helps..

irfansidik
  • 51
  • 3