Comments (6)
Dave, what behavior would you suggest for an in () ? Should the "in ()" be replace with an expression that evaluates to false ?, ex.: 1=2 ?
notIn(Nil) should then return a tautology : 1=1 ...
from squeryl.
Why not just omit the expression node? (The inhibition mechanism might be reusable)
from squeryl.
"in(Nil)" always evaluates to false (it is logically false), omitting the node would evaluate to true, woudln't that be problematic ?
from squeryl.
Well, there could be typed inhibitions, so that when "inhibit = Omissive" (bad naming, I know), the node is simply treated as if it would't change the query, and when "inhibit = Destructive", it is treated as if it would make the query not match. ("bar = 1 or foo in ()" should result in "bar = 1" using such transformations, since "or" can have one destructive operand)
Using Kiama (http://code.google.com/p/kiama/) would also be an alternative, especially for query optimizations and clean-ups in general, but maybe a little overkill?
from squeryl.
Fixed as of :
http://github.com/max-l/Squeryl/commit/4cd99be940a3b7e7315290b32c8df7fbea126162
in () ---> always false (results in this condition being written : "(1 = 0)")
notIn () ---> always true (inhibits the condition)
from squeryl.
This only works if its actually a list, if its an Iterable it appears to bypass this check and blows up. An example with Map.keys follows but it seems to happen with any iterable. Workaround is to call .toList on iterable before passing it to squeryl but I dont think it should compile with an iterable if its going to have a runtime fault like this.
test("Empty list inhibition with iterable"){
transaction {
FooSchema.reset
val foo1 = FooSchema.foos.insert(new Foo("test1"))
val map1 = Map("test1" -> "test1")
val result1 = FooSchema.foos.where(f => f.value in map1.keys).toList
result1 should equal(List(foo1))
//Select
// Foo1.data as Foo1_data,
// Foo1.id as Foo1_id,
// Foo1.value as Foo1_value
//From
// Foo Foo1
//Where
// (Foo1.value in ()) <-- EMPTY!
intercept[Exception]{
val map2 = Map.empty[String, String]
val result2 = FooSchema.foos.where(f => f.value in map2.keys).toList
result2 should equal(Nil)
}
}
}
Full Test Code at https://gist.github.com/795508
Tested against 0.9.4-RC2 and RC3 with mysql adapter.
from squeryl.
Related Issues (20)
- postgres enum type in where clause doesn't work HOT 1
- PrimitiveTypeMode error HOT 1
- support java 8 time classes
- ResultSet not closed properly in operation "headOption"
- Not able to fetch the data from db
- Query generated without column names in select clause like "select from table"
- enable/fix Scala 2.13.0-RC1 test HOT 1
- squeryl.org domain name has expired HOT 1
- Clicking documentation on website gives 404 HOT 1
- java.lang.IncompatibleClassChangeError
- LinkageError on v0.9.14 HOT 1
- [Docs] All code snippets are broken
- Enum serialization and deserialization
- It's not possible to join more then 10 tables HOT 1
- Mapping error on left outer joins with queries as soon as null values are encountered
- schema.create for database that already exists?
- Crashes at initialisation on JDK 17 HOT 3
- scaladoc link got error
- Doc: Getting Started page render wrong result
- Update with composite key
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squeryl.