Hi, I'm pretty new to Sequel but I'm trying to figure something out:

I have this query that limits the dataset to the current user and it looks 
kinda like this:

```
            Model
              .graph(:access_policies,
                     { user_id: user.id, resource_id: :first_account_id) },
                     { table_alias: :ap1 })
              .graph(:accounts,
                     { id: :first_account_id },
                     { table_alias: :a1 })
              .graph(:access_policies,
                     { user_id: user.id, resource_id: :second_account_id },
                     { table_alias: :ap2 })
              .graph(:accounts,
                     { id: :second_account_id },
                     { table_alias: :a2 })
              .where(Sequel.lit('ap1.id is not null and a1.id is not null'))
              .or(Sequel.lit('ap2.id is not null and a2.id is not null'))
```

There's also some code that handles `include=first_account` in the query 
string, which does an .eager_graph on `first_account`.

All good, until `dataset.all` gets called -- then I get a `NoMethodError: 
undefined method `model' for #<Sequel::Postgres::Dataset: "SELECT * FROM 
\"access_policies\"">`

I stepped through the code and it seems to be trying to eager load those 
non-eager graphed associations within `EagerGraphLoader`

It loops through this: `datasets = opts[:graph][:table_aliases]`

and `model` is undefined for each of the table_aliases defined by `graph` 
(not `eager_graph`)

I'm working on a production legacy codebase, so I'm trying to not break the 
auto eager graph stuff -- is there a way I can just tell it which model to 
use for the `graph` calls? Or to skip those for the EagerGraphLoader? Or am 
I doing it all wrong?


-- 
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/d47e4e15-af57-42eb-8c95-3880e6d19ee6n%40googlegroups.com.

Reply via email to