SPOD Postgres bug

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

SPOD Postgres bug

Max S-3
It seems that serializing bool values to integers in spod does not go
well with postgres.
neko.db.Manager.hx:356 should be changed from
    s.add(if( v ) 1 else 0);
to
    s.add(if( v ) "'1'" else "'0");
for Postgres to work or any spod objects with bool fields will fail on
update, insert etc.

Or is there some workaround available?

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Lee Sylvester
Hey Max,

There's a switch in the C source for the ndll that sorts through various
PostgreSQL data types and converts them to Neko values. I'm pretty sure
there's a Boolean value set up in there, but it could probably use
updating. Especially as I used type comparisons that seemed correct at
the time (three years ago), but may have a better match today.

Lee






Max S wrote:

> It seems that serializing bool values to integers in spod does not go
> well with postgres.
> neko.db.Manager.hx:356 should be changed from
>     s.add(if( v ) 1 else 0);
> to
>     s.add(if( v ) "'1'" else "'0");
> for Postgres to work or any spod objects with bool fields will fail on
> update, insert etc.
>
> Or is there some workaround available?
>
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Max S-3
If you mean npostgres.ndll, I don't think it's the problem - haxe SPOD
manager generates query by itself and only uses cnx.quote() from
database-specific code.

2009/10/21 Lee McColl Sylvester <[hidden email]>:

> Hey Max,
>
> There's a switch in the C source for the ndll that sorts through various
> PostgreSQL data types and converts them to Neko values. I'm pretty sure
> there's a Boolean value set up in there, but it could probably use updating.
> Especially as I used type comparisons that seemed correct at the time (three
> years ago), but may have a better match today.
>
> Lee
>
>
>
>
>
>
> Max S wrote:
>>
>> It seems that serializing bool values to integers in spod does not go
>> well with postgres.
>> neko.db.Manager.hx:356 should be changed from
>>    s.add(if( v ) 1 else 0);
>> to
>>    s.add(if( v ) "'1'" else "'0");
>> for Postgres to work or any spod objects with bool fields will fail on
>> update, insert etc.
>>
>> Or is there some workaround available?
>>
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Lee Sylvester
Yes, it generates the code, but the type conversion does have some
reliance on the data that's returned in a resultset.

Lee



Max S wrote:

> If you mean npostgres.ndll, I don't think it's the problem - haxe SPOD
> manager generates query by itself and only uses cnx.quote() from
> database-specific code.
>
> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>  
>> Hey Max,
>>
>> There's a switch in the C source for the ndll that sorts through various
>> PostgreSQL data types and converts them to Neko values. I'm pretty sure
>> there's a Boolean value set up in there, but it could probably use updating.
>> Especially as I used type comparisons that seemed correct at the time (three
>> years ago), but may have a better match today.
>>
>> Lee
>>
>>
>>
>>
>>
>>
>> Max S wrote:
>>    
>>> It seems that serializing bool values to integers in spod does not go
>>> well with postgres.
>>> neko.db.Manager.hx:356 should be changed from
>>>    s.add(if( v ) 1 else 0);
>>> to
>>>    s.add(if( v ) "'1'" else "'0");
>>> for Postgres to work or any spod objects with bool fields will fail on
>>> update, insert etc.
>>>
>>> Or is there some workaround available?
>>>
>>>
>>>      
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>>    
>
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Max S-3
No, the bug is in the SQL code generation, not in reading results. Let
me show you an example:

class User extends neko.db.Object
{
  public var id: Int;
  public var name: String;
  public var email: String;
  public var isactive: Bool;

  static var TABLE_NAME = "Users";
  ...
}

var u = User.get(1);
u.email = '[hidden email]';
u.isactive = true;
u.update();

And spod.Manager.doUpdate() will generate the following query:
UPDATE Users SET email = '[hidden email]', isactive = 1 WHERE id = 1

which will fail because Postgres does not accept integer values for
boolean columns, it needs to be isactive = '1'

2009/10/21 Lee McColl Sylvester <[hidden email]>:

> Yes, it generates the code, but the type conversion does have some reliance
> on the data that's returned in a resultset.
>
> Lee
>
>
>
> Max S wrote:
>>
>> If you mean npostgres.ndll, I don't think it's the problem - haxe SPOD
>> manager generates query by itself and only uses cnx.quote() from
>> database-specific code.
>>
>> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>>
>>>
>>> Hey Max,
>>>
>>> There's a switch in the C source for the ndll that sorts through various
>>> PostgreSQL data types and converts them to Neko values. I'm pretty sure
>>> there's a Boolean value set up in there, but it could probably use
>>> updating.
>>> Especially as I used type comparisons that seemed correct at the time
>>> (three
>>> years ago), but may have a better match today.
>>>
>>> Lee
>>>
>>>
>>>
>>>
>>>
>>>
>>> Max S wrote:
>>>
>>>>
>>>> It seems that serializing bool values to integers in spod does not go
>>>> well with postgres.
>>>> neko.db.Manager.hx:356 should be changed from
>>>>   s.add(if( v ) 1 else 0);
>>>> to
>>>>   s.add(if( v ) "'1'" else "'0");
>>>> for Postgres to work or any spod objects with bool fields will fail on
>>>> update, insert etc.
>>>>
>>>> Or is there some workaround available?
>>>>
>>>>
>>>>
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>>
>>>
>>
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Lee Sylvester
Problem is, it works great in Sqlite and MySQL, so I'd suggest that, in
the ndll, the returned value is checked for 1 or 0 and converted to the
correct value. This would keep everything in sync and save issues when
people upgrade to the next release of haXe.

Lee




Max S wrote:

> No, the bug is in the SQL code generation, not in reading results. Let
> me show you an example:
>
> class User extends neko.db.Object
> {
>   public var id: Int;
>   public var name: String;
>   public var email: String;
>   public var isactive: Bool;
>
>   static var TABLE_NAME = "Users";
>   ...
> }
>
> var u = User.get(1);
> u.email = '[hidden email]';
> u.isactive = true;
> u.update();
>
> And spod.Manager.doUpdate() will generate the following query:
> UPDATE Users SET email = '[hidden email]', isactive = 1 WHERE id = 1
>
> which will fail because Postgres does not accept integer values for
> boolean columns, it needs to be isactive = '1'
>
> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>  
>> Yes, it generates the code, but the type conversion does have some reliance
>> on the data that's returned in a resultset.
>>
>> Lee
>>
>>
>>
>> Max S wrote:
>>    
>>> If you mean npostgres.ndll, I don't think it's the problem - haxe SPOD
>>> manager generates query by itself and only uses cnx.quote() from
>>> database-specific code.
>>>
>>> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>>>
>>>      
>>>> Hey Max,
>>>>
>>>> There's a switch in the C source for the ndll that sorts through various
>>>> PostgreSQL data types and converts them to Neko values. I'm pretty sure
>>>> there's a Boolean value set up in there, but it could probably use
>>>> updating.
>>>> Especially as I used type comparisons that seemed correct at the time
>>>> (three
>>>> years ago), but may have a better match today.
>>>>
>>>> Lee
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Max S wrote:
>>>>
>>>>        
>>>>> It seems that serializing bool values to integers in spod does not go
>>>>> well with postgres.
>>>>> neko.db.Manager.hx:356 should be changed from
>>>>>   s.add(if( v ) 1 else 0);
>>>>> to
>>>>>   s.add(if( v ) "'1'" else "'0");
>>>>> for Postgres to work or any spod objects with bool fields will fail on
>>>>> update, insert etc.
>>>>>
>>>>> Or is there some workaround available?
>>>>>
>>>>>
>>>>>
>>>>>          
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>>>
>>>>
>>>>        
>>>      
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>>    
>
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Max S-3
Well, it works in MySQL only because MySQL does not have boolean
column values and column type is usually set to smallint(1) or
something. The right thing to do would be to call database-specific
conversion in the current database module from the SPOD.

2009/10/21 Lee McColl Sylvester <[hidden email]>:

> Problem is, it works great in Sqlite and MySQL, so I'd suggest that, in the
> ndll, the returned value is checked for 1 or 0 and converted to the correct
> value. This would keep everything in sync and save issues when people
> upgrade to the next release of haXe.
>
> Lee
>
>
>
>
> Max S wrote:
>>
>> No, the bug is in the SQL code generation, not in reading results. Let
>> me show you an example:
>>
>> class User extends neko.db.Object
>> {
>>  public var id: Int;
>>  public var name: String;
>>  public var email: String;
>>  public var isactive: Bool;
>>
>>  static var TABLE_NAME = "Users";
>>  ...
>> }
>>
>> var u = User.get(1);
>> u.email = '[hidden email]';
>> u.isactive = true;
>> u.update();
>>
>> And spod.Manager.doUpdate() will generate the following query:
>> UPDATE Users SET email = '[hidden email]', isactive = 1 WHERE id = 1
>>
>> which will fail because Postgres does not accept integer values for
>> boolean columns, it needs to be isactive = '1'
>>
>> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>>
>>>
>>> Yes, it generates the code, but the type conversion does have some
>>> reliance
>>> on the data that's returned in a resultset.
>>>
>>> Lee
>>>
>>>
>>>
>>> Max S wrote:
>>>
>>>>
>>>> If you mean npostgres.ndll, I don't think it's the problem - haxe SPOD
>>>> manager generates query by itself and only uses cnx.quote() from
>>>> database-specific code.
>>>>
>>>> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>>>>
>>>>
>>>>>
>>>>> Hey Max,
>>>>>
>>>>> There's a switch in the C source for the ndll that sorts through
>>>>> various
>>>>> PostgreSQL data types and converts them to Neko values. I'm pretty sure
>>>>> there's a Boolean value set up in there, but it could probably use
>>>>> updating.
>>>>> Especially as I used type comparisons that seemed correct at the time
>>>>> (three
>>>>> years ago), but may have a better match today.
>>>>>
>>>>> Lee
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Max S wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> It seems that serializing bool values to integers in spod does not go
>>>>>> well with postgres.
>>>>>> neko.db.Manager.hx:356 should be changed from
>>>>>>  s.add(if( v ) 1 else 0);
>>>>>> to
>>>>>>  s.add(if( v ) "'1'" else "'0");
>>>>>> for Postgres to work or any spod objects with bool fields will fail on
>>>>>> update, insert etc.
>>>>>>
>>>>>> Or is there some workaround available?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> haXe - an open source web programming language
>>>>> http://haxe.org
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>>
>>>
>>
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Lee Sylvester
I'm happy for that in nPostgres because I don't believe that many people
are using it, but whatever changes you suggest, try to put backwards
compatible checks there for MySQL / Sqlite or make sure that it won't
impact devs using the currently working model.

:-)

Lee





Max S wrote:

> Well, it works in MySQL only because MySQL does not have boolean
> column values and column type is usually set to smallint(1) or
> something. The right thing to do would be to call database-specific
> conversion in the current database module from the SPOD.
>
> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>  
>> Problem is, it works great in Sqlite and MySQL, so I'd suggest that, in the
>> ndll, the returned value is checked for 1 or 0 and converted to the correct
>> value. This would keep everything in sync and save issues when people
>> upgrade to the next release of haXe.
>>
>> Lee
>>
>>
>>
>>
>> Max S wrote:
>>    
>>> No, the bug is in the SQL code generation, not in reading results. Let
>>> me show you an example:
>>>
>>> class User extends neko.db.Object
>>> {
>>>  public var id: Int;
>>>  public var name: String;
>>>  public var email: String;
>>>  public var isactive: Bool;
>>>
>>>  static var TABLE_NAME = "Users";
>>>  ...
>>> }
>>>
>>> var u = User.get(1);
>>> u.email = '[hidden email]';
>>> u.isactive = true;
>>> u.update();
>>>
>>> And spod.Manager.doUpdate() will generate the following query:
>>> UPDATE Users SET email = '[hidden email]', isactive = 1 WHERE id = 1
>>>
>>> which will fail because Postgres does not accept integer values for
>>> boolean columns, it needs to be isactive = '1'
>>>
>>> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>>>
>>>      
>>>> Yes, it generates the code, but the type conversion does have some
>>>> reliance
>>>> on the data that's returned in a resultset.
>>>>
>>>> Lee
>>>>
>>>>
>>>>
>>>> Max S wrote:
>>>>
>>>>        
>>>>> If you mean npostgres.ndll, I don't think it's the problem - haxe SPOD
>>>>> manager generates query by itself and only uses cnx.quote() from
>>>>> database-specific code.
>>>>>
>>>>> 2009/10/21 Lee McColl Sylvester <[hidden email]>:
>>>>>
>>>>>
>>>>>          
>>>>>> Hey Max,
>>>>>>
>>>>>> There's a switch in the C source for the ndll that sorts through
>>>>>> various
>>>>>> PostgreSQL data types and converts them to Neko values. I'm pretty sure
>>>>>> there's a Boolean value set up in there, but it could probably use
>>>>>> updating.
>>>>>> Especially as I used type comparisons that seemed correct at the time
>>>>>> (three
>>>>>> years ago), but may have a better match today.
>>>>>>
>>>>>> Lee
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Max S wrote:
>>>>>>
>>>>>>
>>>>>>            
>>>>>>> It seems that serializing bool values to integers in spod does not go
>>>>>>> well with postgres.
>>>>>>> neko.db.Manager.hx:356 should be changed from
>>>>>>>  s.add(if( v ) 1 else 0);
>>>>>>> to
>>>>>>>  s.add(if( v ) "'1'" else "'0");
>>>>>>> for Postgres to work or any spod objects with bool fields will fail on
>>>>>>> update, insert etc.
>>>>>>>
>>>>>>> Or is there some workaround available?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>> --
>>>>>> haXe - an open source web programming language
>>>>>> http://haxe.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>>>>          
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>>>
>>>>
>>>>        
>>>      
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>>    
>
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Thomas-8
On Wed, Oct 21, 2009 at 8:36 PM, Lee McColl Sylvester
<[hidden email]> wrote:
> I'm happy for that in nPostgres because I don't believe that many people are
> using it
Well it was not easy to get it to compile on my mac and debian
machines, so I guess people simply turn over to mysql.

I wish I knew how to create a makefile...

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Lee Sylvester
Yeah, me too. Always something I'd planned to pick up at some point. I'm
a mean bast*rd with Visual Studio, but makefiles have always eluded me...

Anyone know of a good book or online resource that details Makefiles and
C/C++ programming for Linux / Mac OSX?

Lee




Thomas wrote:

> On Wed, Oct 21, 2009 at 8:36 PM, Lee McColl Sylvester
> <[hidden email]> wrote:
>  
>> I'm happy for that in nPostgres because I don't believe that many people are
>> using it
>>    
> Well it was not easy to get it to compile on my mac and debian
> machines, so I guess people simply turn over to mysql.
>
> I wish I knew how to create a makefile...
>
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Randy Stauner
i just recently got my feet wet with Makefiles.
I enjoy them, but everything I learned I learned from the command line: `info make`
Of course that also involved looking up the manual for the textinfo command to learn how to navigate that.

On Wed, Oct 21, 2009 at 12:01 PM, Lee McColl Sylvester <[hidden email]> wrote:
Yeah, me too. Always something I'd planned to pick up at some point. I'm a mean bast*rd with Visual Studio, but makefiles have always eluded me...

Anyone know of a good book or online resource that details Makefiles and C/C++ programming for Linux / Mac OSX?

Lee





Thomas wrote:
On Wed, Oct 21, 2009 at 8:36 PM, Lee McColl Sylvester
<[hidden email]> wrote:
 
I'm happy for that in nPostgres because I don't believe that many people are
using it
   
Well it was not easy to get it to compile on my mac and debian
machines, so I guess people simply turn over to mysql.

I wish I knew how to create a makefile...

 


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD Postgres bug

Lee Sylvester
Thanks, that could be the way to go, then :-)


Randy Stauner wrote:

> i just recently got my feet wet with Makefiles.
> I enjoy them, but everything I learned I learned from the command
> line: `info make`
> Of course that also involved looking up the manual for the textinfo
> command to learn how to navigate that.
>
> On Wed, Oct 21, 2009 at 12:01 PM, Lee McColl Sylvester
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Yeah, me too. Always something I'd planned to pick up at some
>     point. I'm a mean bast*rd with Visual Studio, but makefiles have
>     always eluded me...
>
>     Anyone know of a good book or online resource that details
>     Makefiles and C/C++ programming for Linux / Mac OSX?
>
>     Lee
>
>
>
>
>
>     Thomas wrote:
>
>         On Wed, Oct 21, 2009 at 8:36 PM, Lee McColl Sylvester
>         <[hidden email] <mailto:[hidden email]>> wrote:
>          
>
>             I'm happy for that in nPostgres because I don't believe
>             that many people are
>             using it
>                
>
>         Well it was not easy to get it to compile on my mac and debian
>         machines, so I guess people simply turn over to mysql.
>
>         I wish I knew how to create a makefile...
>
>          
>
>
>
>     --
>     haXe - an open source web programming language
>     http://haxe.org
>
>


--
haXe - an open source web programming language
http://haxe.org