Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Feedback requested on minor change to operator handling for +, &, and |
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeremy Evans  
View profile  
 More options Sep 17 2011, 1:52 pm
From: Jeremy Evans <jeremyeva...@gmail.com>
Date: Sat, 17 Sep 2011 10:52:24 -0700 (PDT)
Local: Sat, Sep 17 2011 1:52 pm
Subject: Re: Feedback requested on minor change to operator handling for +, &, and |
On Sep 17, 10:22 am, funny_falcon <funny.fal...@gmail.com> wrote:

> I'm not sure that library should guess for user which operator to use, (just
> my opinion).

In this case, it's not really guessing, it's just using types.  If you
see the ruby expression "x + 'a'", you would assume a string
concatenation operation.  If you see a ruby "x & 1" operation, you
would assume a bitwise operation.  This just updates the code to make
Sequel act more like ruby.  Since it doesn't know the type of column x
if you do ":x + 'a'", it can either generate an addition or
concatenation operation, and I think concatentation makes more sense.

Before, you would need to do ":x.sql_string + 'a'" or ":x.sql_number &
1", this just removes the need for those methods.

> In case user really wants to make `((x+1)||'a')` in SQL, what should he do
> after applying this patch?

That isn't the operator guessing part of the patch, and I don't think
such a thing was supported before (NumericExpression doesn't implement
sql_string).  || on most database types will automatically convert
numerics to strings, so I probably should at least take out the code
that disallows numeric and boolean expressions in string expressions.
To support that, I could make the following work:

  (:x + 1).sql_string + 'a'

Jeremy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.