A segunda-feira, 13 de dezembro de 2021 à(s) 18:12:19 UTC, Jeremy Evans 
escreveu:

> On Mon, Dec 13, 2021 at 9:03 AM Tiago Cardoso <[email protected]> 
> wrote:
>
>> .intersect is definitely not covering my use-case.
>>
>
> Could you explain why?  For the example you gave, results should be 
> identical.
>

The example above is probably not matching the real use-case I'd like to 
cover, which is found here: 
https://gitlab.com/honeyryderchuck/rodauth-oauth/-/merge_requests/69/diffs#eba3d8d3b7f624088a30cbc09948382d6dd2354e_687_702,
 
which blows with "Sequel::DatabaseError: SQLite3::SQLException: SELECTs to 
the left and right of INTERSECT do not have the same number of result 
columns" in the test suite if I use ".intersect", which I assume isn't to 
be used with joined tables.

 

>
> I'd be for a simple Dataset#merge_where, but as you said, it's relatively 
>> simple to do it. My only concerns would be if messing with Dataset#opts 
>> would be considered implementation detail and private-ish API. If I can 
>> rely on it working further on, your (improved) suggestion works fairly well.
>>
>
> Dataset#opts is public.  Specific contents could change 
> version-to-version, but it seems unlikely that it would change 
> significantly enough to break direct usage of opts[:where].
>

Good enough for me, at least for this case.
 

>  
>
>> If you ever change your mind about Dataset#merge, I guess that it'd be 
>> possible to constrain it to handle only "simple" cases (i.e. no different 
>> tables, but potentially handling merging joins, conditions, ...). I know 
>> that AR supports something of the kind, which has worked in the past for me 
>> for the simple cases, but you might know quite a bit more about the 
>> implementation overhead than me.
>>
>
> I 100% want to avoid AR's issues with #merge.  Look Rails 7.0 CHANGELOG 
> for AR (
> https://github.com/rails/rails/blob/7-0-stable/activerecord/CHANGELOG.md) 
> and search for "merge".  Please let me know what you think about the 
> behavior.
>
>  

> If you look at the reasoning behind merge given in the AR documentation: 
> "This is mainly intended for sharing common conditions between multiple 
> associations.".  Due to Sequel's extensive support for SQL expression 
> objects as part of it's API (instead of SQL string fragments with 
> placeholders), you can almost always share common conditions in a Sequel 
> object, and use the shared conditions in multiple datasets.
>

I'm definitely in favour of not importing AR's maintenance burden to 
sequel. I guess I was looking for a "terser" way for doing what I am in the 
linked example above, but perhaps it's not AR's merge feature, and I'm best 
served with Dataset#opts already.


> 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/86d67ea2-0c83-4335-95f2-9a87098c3fa7n%40googlegroups.com.

Reply via email to