Hi Jeremy,
We are heavily using Sequel in PostgreSQL (dev/staging) / Redshift (prod)
environment, so sometimes we have to keep adapter specific code, and
recently some expressions where added like this:
module Sequel
# a NULL-safe "not equal" comparison condition
# (
# (a IS NULL AND b IS NOT NULL) OR
# (a IS NOT NULL AND b IS NULL) OR
# (a <> b)
# )
def self.is_distinct_from(a, b)
if defined?(DB) == 'constant' && DB.adapter_scheme == :redshift
(Sequel[a] =~ nil) & (Sequel[b] !~ nil) |
(Sequel[a] !~ nil) & (Sequel[b] =~ nil) |
(Sequel[a] !~ Sequel[b])
else
Sequel.lit('? IS DISTINCT FROM ?', a, b)
end
end
module Timezones
def timezone_fn(timezone, field)
fn = if defined?(DB) == 'constant' && DB.adapter_scheme == :redshift
'CONVERT_TIMEZONE'
else
'timezone'
end
Sequel.lit("#{fn}(?, ?)", timezone, field)
end
end
end
It works, but it's not very nice momkey-patching, can point me to some
example in the code - the way it should be done properly?
I tried to add it into SQL Builders module but it didn't work for me,
probably I missed something.
We keeping a fork of "working for us" redshift adapter for sequel here
https://github.com/attribution/sequel-redshift
<https://github.com/attribution/sequel-redshift/commit/8d2828706970c6fd7661909315b5eecde9759bb7#diff-05c70fb8a8093e49de9c56c14213044cR125>
Btw had to copy whole class here just to add ":redshift" to the case
statement:
https://github.com/attribution/sequel-redshift/commit/8d2828706970c6fd7661909315b5eecde9759bb7#diff-05c70fb8a8093e49de9c56c14213044cR125
Thanks for your hard work on sequel, our new devs hate it at first, but
couple months later they can't live without it anymore ;) Great gem!
--
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/f52132c9-a272-4e24-8bfd-aa8b37150522%40googlegroups.com.