Repository navigation
Conversation
| void appendTo(Insert.Options usings) { | ||
| throw new UnsupportedOperationException("shouldn't be called"); | ||
| void validate(QueryType qt, MappingManager manager) { | ||
| checkArgument(qt == QueryType.SAVE || qt == QueryType.DEL || qt == QueryType.GET, |
There was a problem hiding this comment.
Just noticed: this check is useless, these is no other QueryType at this moment.
| void appendTo(Insert.Options usings) { | ||
| throw new UnsupportedOperationException("shouldn't be called"); | ||
| void validate(QueryType qt, MappingManager manager) { | ||
| checkArgument(qt == QueryType.SAVE || qt == QueryType.DEL || qt == QueryType.GET, |
| * Options may also affect the statement itself, not a bound variable; in that case, the | ||
| * method must return the index unchanged. | ||
| */ | ||
| abstract int bind(BoundStatement bs, int currentIndex); |
There was a problem hiding this comment.
bind sounds a bit ambiguous to me since the implementations are going to either bind a parameter, or set an option on the statement. Couldn't we call it something like applyOption?
|
|
||
| final Type type; | ||
|
|
||
| protected Option(Type type) { |
There was a problem hiding this comment.
Just noticed that I don't think protected is actually helpful here, I think it can go package-private. Since the other abstract methods on Option are package-private, I don't think we can expect anybody outside the driver to extends Option because of the package private abstract methods, and so the only implementations possible are in this package
| * Otherwise, comparing the class is good enough. See subclasses for examples. | ||
| */ | ||
| @Override | ||
| public abstract boolean equals(Object other); |
There was a problem hiding this comment.
Isn't it misleading that we end up with different options with different values being equal? Meaning Option.ttl(1).equals(Option.ttl(2)) // => true
There was a problem hiding this comment.
Fair enough, the option values are exposed to the end user after all. I've added an asCacheKey method to improve this.
|
I think we need to add a rule in Clirr: I don't think users would address Options separately (just always pass in Option / never look at it), so it is probably ok to add an exception, wdyt? |
|
On second thought, it seems like it wouldn't be a problem to add |
|
|
||
| @Override | ||
| void validate(QueryType qt, MappingManager manager) { | ||
| checkArgument(qt == QueryType.SAVE, "IfNotExists option is only allowed in save queries"); |
There was a problem hiding this comment.
Could technically protocol version check here like we do for TTLs, although LWTs aren't tied to protocol version but CQL/C* version instead ( so maybe it's best the way it is since we can't reliably check if the C* server will support it)
|
Ah, type itself was protected to begin with, so even though the API method was present, you couldn't use it for comparison purposes...sounds like clirr rule is more appropriate after all. |
|
Went ahead and added the clirr exception, feel free to back out if disagree. Also added a couple negative tests. |
|
Good catch. The public getType was an oversight, but just to be safe I think it's better to keep it and deprecate it. |
|
Just remembered, it would be good to add the new option to the manual where we document the rest of the mapper options. |
- improve method names - prepare for options that require different prepared statements depending on their value
|
Done |
No description provided.