These all generate the correct SQL, and if I change the definition of not_ebook in the scope then every SQL is automatically changed to the new definition. There are 18 places in our system where #not_ebook is used, and not only would I not want to correct them all by hand, I would not fancy my chances of being sure that I can find them all.
So that's pretty hard to do with SQL, efficiently at least. You could conceive of it being done with a PL./SQL function in Oracle perhaps, but when you stray from executing pure SQL there's the risk of compromising performance.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sure – I think that scopes are a good example.
The ability to define something as simple as:
So these define class methods that I can daisy chain in the application to be able to identify the records I want:
Book.not_ebook
Book.sales_present.not_ebook
Book.not_ebook.sales_present.publishing_within_months(1)
These all generate the correct SQL, and if I change the definition of
not_ebook
in the scope then every SQL is automatically changed to the new definition. There are 18 places in our system where#not_ebook
is used, and not only would I not want to correct them all by hand, I would not fancy my chances of being sure that I can find them all.So that's pretty hard to do with SQL, efficiently at least. You could conceive of it being done with a PL./SQL function in Oracle perhaps, but when you stray from executing pure SQL there's the risk of compromising performance.