On Tue, Aug 24, 2021 at 2:22 AM Vysakh Sreenivasan <[email protected]>
wrote:
> Hi
>
>
> *sample = DB[Sequel[:public][:sample]]sample.first*
>
> This works fine. But
>
>
> *class SampleModel < Sequel::Model(sample); end*
>
> throws an exception. I'm using rockset database through their JDBC
> adapter. Based on Base.rb in sequel code, I see the schema is being fetched
> and all the related columns are being fetched, I suspect if that's where
> the code fails.
>
You could try using the same dataset:
class SampleModel < Sequel::Model(DB[Sequel[:public][:sample]]); end
Note that Sequel does not have a jdbc subadapter for Rocksetdb, so it is
using the generic support in the jdbc adapter. The JDBC driver for
Rocksetdb apparently does not return tables in the public schema if the
public schema is not explicitly provided.
> For eg:
>
> *DB.tables*
>
> This fails but
>
> *DB.tables(:schema => :public)*
>
>
You can do this manually (this is for tables, similar overrides can be made
for other methods such as DB.schema.
def DB.tables(opts={})
opts[:schema] ? super : super(opts.merge(:schema=>:public))
end
This works. Initially I had a different schema (called: "common"), I
> thought making it into public would help Sequel infer the columns and the
> model would work, but it doesn't seem to work.
>
> I was wondering if somehow set the schema name like *DB.set_schema_name *or
> load the entire database schema, then this would work.
>
Sequel doesn't support a feature like that. On PostgreSQL, you can use the
:search_path option to specify the schema order to use for unqualified
references. But that relies on PostgreSQL support, it's not something
where Sequel is actively checking the search path.
> I'm trying to get the Sequel Model get working but couldn't make a
> progress, I can get it working through the non-model approach, through
> dataset. But I don't want to lose out on the features that Model brings in.
> Appreciate any help.
>
As shown above, you can pass a dataset to Sequel::Model. That should be
the simplest way to solve your issue.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSSf8g1zuj0nNcDkjRLa5LbjCMn2Pgo4EdRVkmFAOv_uNSg%40mail.gmail.com.