New package sys.db / SPOD changes

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

New package sys.db / SPOD changes

Nicolas Cannasse
Hi,

As part of the transitional process to haXe 3.0 I have added on SVN the
sys.db package that will merge both php.db and neko.db (and add maybe
support for cpp when available).

The sys.db package contains also the new version for SPOD which is based
on macros (will be documented soon). I have added tested implementation
that works for Neko, and I'm looking for someone to test with PHP.

One change in this version of SPOD is that binary types (BLOB, BINARY,
etc.) are now wrapped as haxe.io.Bytes instead of String. This require
1.8.2 NekoVM version (to be released soon).

You can use this new SPOD version by compiling with -D spod_macro and
use the sys.db.* classes : this will also disable neko.db and php.db
package classes so you can make sure to rename everything by using the
sys.db package.

You can also continue to use neko.db or php.db without -D spod_macro,
but you will not get the new SPOD version.

Best,
Nicolas

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

Re: New package sys.db / SPOD changes

jlm@justinfront.net
Nicolas

That's great news, what's the viability of similar for the C++ target  
also having sys.db? Anyone up for developing that?

Cheers

;j


On 22 Aug 2011, at 14:30, Nicolas Cannasse wrote:

> Hi,
>
> As part of the transitional process to haXe 3.0 I have added on SVN  
> the sys.db package that will merge both php.db and neko.db (and add  
> maybe support for cpp when available).
>
> The sys.db package contains also the new version for SPOD which is  
> based on macros (will be documented soon). I have added tested  
> implementation that works for Neko, and I'm looking for someone to  
> test with PHP.
>
> One change in this version of SPOD is that binary types (BLOB,  
> BINARY, etc.) are now wrapped as haxe.io.Bytes instead of String.  
> This require 1.8.2 NekoVM version (to be released soon).
>
> You can use this new SPOD version by compiling with -D spod_macro  
> and use the sys.db.* classes : this will also disable neko.db and  
> php.db package classes so you can make sure to rename everything by  
> using the sys.db package.
>
> You can also continue to use neko.db or php.db without -D  
> spod_macro, but you will not get the new SPOD version.
>
> Best,
> Nicolas
>
> --
> 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: New package sys.db / SPOD changes

postite
Do you mean spod_macros now works targetting php ?
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: New package sys.db / SPOD changes

Nicolas Cannasse
Le 22/08/2011 15:56, dav kert a écrit :
> Do you mean spod_macros now works targetting php ?

Not yet : I'm actually looking for someone that can propose a small
patch to sys.db.Manager to correctly support PHP.

I made half the work by using a _lock flag in neko.db.Object instead of
hacking the update() method which was very neko-specific behavior. Now
there's the cache and relations to support : we can actually generate
stub code for relations thanks to build macro, or rely on a runtime
getter/setter injection as it's being done currently for Neko.

Best,
Nicolas

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

Re: New package sys.db / SPOD changes

Jason O'Neil
In reply to this post by Nicolas Cannasse

Hi Nicolas

Sounds fantastic!

I'm looking forward to testing it later in the week. If no-one has helped with php by then I can have a look.  I'm one of the weird haxe users that uses almost exclusively the php/js targets, so this is of great interest to me :)

Jason

On Aug 22, 2011 9:32 PM, "Nicolas Cannasse" <[hidden email]> wrote:
> Hi,
>
> As part of the transitional process to haXe 3.0 I have added on SVN the
> sys.db package that will merge both php.db and neko.db (and add maybe
> support for cpp when available).
>
> The sys.db package contains also the new version for SPOD which is based
> on macros (will be documented soon). I have added tested implementation
> that works for Neko, and I'm looking for someone to test with PHP.
>
> One change in this version of SPOD is that binary types (BLOB, BINARY,
> etc.) are now wrapped as haxe.io.Bytes instead of String. This require
> 1.8.2 NekoVM version (to be released soon).
>
> You can use this new SPOD version by compiling with -D spod_macro and
> use the sys.db.* classes : this will also disable neko.db and php.db
> package classes so you can make sure to rename everything by using the
> sys.db package.
>
> You can also continue to use neko.db or php.db without -D spod_macro,
> but you will not get the new SPOD version.
>
> Best,
> Nicolas
>
> --
> 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: New package sys.db / SPOD changes

Julien CASTETS
Hi Nicolas,

Great news. I have some time and motivation to build my projects with the latest version of haxe.

getFieldsName implementation is missing in php.db.MysqlResultSet, that I patched following getFieldsDescription.

Note that this is when spod_macro is not used.

Hope it helps
Best
Julien

2011/8/22 Jason O'Neil <[hidden email]>

Hi Nicolas

Sounds fantastic!

I'm looking forward to testing it later in the week. If no-one has helped with php by then I can have a look.  I'm one of the weird haxe users that uses almost exclusively the php/js targets, so this is of great interest to me :)

Jason

On Aug 22, 2011 9:32 PM, "Nicolas Cannasse" <[hidden email]> wrote:
> Hi,
>
> As part of the transitional process to haXe 3.0 I have added on SVN the
> sys.db package that will merge both php.db and neko.db (and add maybe
> support for cpp when available).
>
> The sys.db package contains also the new version for SPOD which is based
> on macros (will be documented soon). I have added tested implementation
> that works for Neko, and I'm looking for someone to test with PHP.
>
> One change in this version of SPOD is that binary types (BLOB, BINARY,
> etc.) are now wrapped as haxe.io.Bytes instead of String. This require
> 1.8.2 NekoVM version (to be released soon).
>
> You can use this new SPOD version by compiling with -D spod_macro and
> use the sys.db.* classes : this will also disable neko.db and php.db
> package classes so you can make sure to rename everything by using the
> sys.db package.
>
> You can also continue to use neko.db or php.db without -D spod_macro,
> but you will not get the new SPOD version.
>
> Best,
> Nicolas
>
> --
> 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

php_resultset_getFieldNames.patch (840 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: New package sys.db / SPOD changes

paling
In reply to this post by jlm@justinfront.net
SPOD is that binary types (BLOB, BINARY,
etc.) are now wrapped as haxe.io.Bytes instead of String

Great
Is in need of
helpful
Reply | Threaded
Open this post in threaded view
|

Re: New package sys.db / SPOD changes

Nicolas Cannasse
In reply to this post by Julien CASTETS
Le 22/08/2011 17:56, Julien CASTETS a écrit :
> Hi Nicolas,
>
> Great news. I have some time and motivation to build my projects with
> the latest version of haxe.
>
> getFieldsName implementation is missing in php.db.MysqlResultSet, that I
> patched following getFieldsDescription.

Thanks, fixed.

Nicolas

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

Re: New package sys.db / SPOD changes

Julien CASTETS
Hi,

I'm starting to try spod_macro targeting php. I made a simple test project as a sandbox for learning/testing.
Here is my first problem, the sys.db.Mysql class is not generated when compiling to php even with a compilation success.
I get this error at runtime "Debug Error: /php_spod_macro_test/lib/Main.class.php line 14 - Class 'sys_db_Mysql' not found"

Could you tell me if I'm misusing something, here is the code

package ;

import haxe.Resource;
import php.Lib;
import sys.db.Mysql;

class Main
{
static function println(v:Dynamic)
{
Lib.print(v + '<br />');
}
static function main() 
{
sys.db.Manager.cnx = Mysql.connect( {
user:"root",
pass:"root",
host:"spodmacro.home.test",
database:"php_spod_macro_test",
port:3306,
socket:null
} );
/*
var o = new SpodTypes();
o.bigint = 18446744073709551615.0;
o.float = 3.1415;
o.bool = 1==1;
o.varchar = "This is a varchar.";
o.date = Date.now();
o.datetime = Date.now();
o.blob = Resource.getBytes("haxelogo");
o.nullable = null;
o.skipable = 42;
o.insert();
println(o.id);*/
}

}

Thank you
Best
Julien

2011/8/26 Nicolas Cannasse <[hidden email]>
Le 22/08/2011 17:56, Julien CASTETS a écrit :

Hi Nicolas,

Great news. I have some time and motivation to build my projects with
the latest version of haxe.

getFieldsName implementation is missing in php.db.MysqlResultSet, that I
patched following getFieldsDescription.

Thanks, fixed.


Nicolas

--
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: New package sys.db / SPOD changes

Nicolas Cannasse
Le 26/08/2011 16:13, Julien CASTETS a écrit :
> Hi,
>
> I'm starting to try spod_macro targeting php. I made a simple test
> project as a sandbox for learning/testing.
> Here is my first problem, the sys.db.Mysql class is not generated when
> compiling to php even with a compilation success.
> I get this error at runtime "Debug Error:
> /php_spod_macro_test/lib/Main.class.php line 14 - Class 'sys_db_Mysql'
> not found"

Added on SVN.

Please note that this version needs to be modified in order to support
translation of binary types "blob" etc. to haxe.io.Bytes : please
provide a patch if you have time for it ;)

Best,
Nicolas

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

Re: New package sys.db / SPOD changes

Julien CASTETS
Thank you.

I'll do my best to make it work if I can :)

I'm now stuck with another issue, I guess the prototype field on a Class<T>  is missing on php target.
I'm not sure of what I'm saying but testing with the following code (based on what's not working in sys.db.Manager)

package ;

 class Foo
 {
public function new(){}
 }
 
class Main 
{
var t : { prototype:Dynamic };
function new()
{
t = cast Foo;
trace(t.prototype);
}
static function main() 
{
new Main();
}
}

For php the trace is 'null'
For neko the trace is '{ __class__ => { __name__ => [Foo], __construct__ => #function:0, prototype => ..., new
=> #function:0 }, __serialize => #function:0 }
'

So maybe this is a problem with the php generator ?

Hope it helps
Julien

2011/8/26 Nicolas Cannasse <[hidden email]>
Le 26/08/2011 16:13, Julien CASTETS a écrit :

Hi,

I'm starting to try spod_macro targeting php. I made a simple test
project as a sandbox for learning/testing.
Here is my first problem, the sys.db.Mysql class is not generated when
compiling to php even with a compilation success.
I get this error at runtime "Debug Error:
/php_spod_macro_test/lib/Main.class.php line 14 - Class 'sys_db_Mysql'
not found"

Added on SVN.

Please note that this version needs to be modified in order to support translation of binary types "blob" etc. to haxe.io.Bytes : please provide a patch if you have time for it ;)

Best,

Nicolas

--
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: New package sys.db / SPOD changes

Julien CASTETS
Okay, I think maybe "prototype" is a magic thing related to neko.

So here is my understanding of this piece of code (from sys.db.Manager::new)

var class_proto : { prototype : Dynamic };
...
class_proto = cast classval;
class_proto.prototype._manager = this;

The goal here is to set the _manager property of the current sys.db.Object subclass to get only one Manager instance by sys.db.Object subclass

Am I correct ? If yes I've no clue on how to do this with php.

Anyway I've get the insert function working by hacking a bit like this

@:autoBuild(sys.db.SpodMacros.macroBuild())
class Object {

var _locked(default,never) : Bool;
var _manager(getManager, never) : sys.db.Manager<Dynamic>;

function getManager() {
untyped return _manager;
}
...


class SpodTypes extends Object
{
public var id:SUId;
public var bigint:SBigInt;
public var float:SFloat;
public var bool:SBool;
public var varchar:SString<45>;
public var date:SDate;
public var datetime:SDateTime;
public var blob:SSmallBinary;
public var nullable:SNull<Int>;
@:skip 
public var skipable:Int;
public function new() {
super();
}
override function getManager() {
return untyped manager;
}
}

Maybe this could be done with macro but I'm quite confused now and I'm not sure this is THE solution :)

BTW I'll keep going on and let you know.

Best
Julien


2011/8/27 Julien CASTETS <[hidden email]>
Thank you.

I'll do my best to make it work if I can :)

I'm now stuck with another issue, I guess the prototype field on a Class<T>  is missing on php target.
I'm not sure of what I'm saying but testing with the following code (based on what's not working in sys.db.Manager)

package ;

 class Foo
 {
public function new(){}
 }
 
class Main 
{
var t : { prototype:Dynamic };
function new()
{
t = cast Foo;
trace(t.prototype);
}
static function main() 
{
new Main();
}
}

For php the trace is 'null'
For neko the trace is '{ __class__ => { __name__ => [Foo], __construct__ => #function:0, prototype => ..., new
=> #function:0 }, __serialize => #function:0 }
'

So maybe this is a problem with the php generator ?

Hope it helps
Julien

2011/8/26 Nicolas Cannasse <[hidden email]>
Le 26/08/2011 16:13, Julien CASTETS a écrit :

Hi,

I'm starting to try spod_macro targeting php. I made a simple test
project as a sandbox for learning/testing.
Here is my first problem, the sys.db.Mysql class is not generated when
compiling to php even with a compilation success.
I get this error at runtime "Debug Error:
/php_spod_macro_test/lib/Main.class.php line 14 - Class 'sys_db_Mysql'
not found"

Added on SVN.

Please note that this version needs to be modified in order to support translation of binary types "blob" etc. to haxe.io.Bytes : please provide a patch if you have time for it ;)

Best,

Nicolas

--
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: New package sys.db / SPOD changes

Nicolas Juneau
In reply to this post by Nicolas Cannasse
I haven't checked out the SVN, but will the new SPOD support many-to-many
relationships?

Le 22 août 2011 09:30:06, Nicolas Cannasse a écrit :

> Hi,
>
> As part of the transitional process to haXe 3.0 I have added on SVN the
> sys.db package that will merge both php.db and neko.db (and add maybe
> support for cpp when available).
>
> The sys.db package contains also the new version for SPOD which is based
> on macros (will be documented soon). I have added tested implementation
> that works for Neko, and I'm looking for someone to test with PHP.
>
> One change in this version of SPOD is that binary types (BLOB, BINARY,
> etc.) are now wrapped as haxe.io.Bytes instead of String. This require
> 1.8.2 NekoVM version (to be released soon).
>
> You can use this new SPOD version by compiling with -D spod_macro and
> use the sys.db.* classes : this will also disable neko.db and php.db
> package classes so you can make sure to rename everything by using the
> sys.db package.
>
> You can also continue to use neko.db or php.db without -D spod_macro,
> but you will not get the new SPOD version.
>
> Best,
> Nicolas
--
Nicolas Juneau

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

Re: New package sys.db / SPOD changes

Andreas Mokros
In reply to this post by Nicolas Cannasse
Hi Nicolas.

On Mon, 22 Aug 2011 15:30:06 +0200
Nicolas Cannasse <[hidden email]> wrote:
> You can use this new SPOD version by compiling with -D spod_macro and
> use the sys.db.* classes

Useful update. One question:
sys.db.Object does not have sync() function anymore?
respectively sys.db.Manager does not have doSync()?

--
Mockey

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

Re: New package sys.db / SPOD changes

Nicolas Cannasse
Le 28/08/2011 23:33, Andreas Mokros a écrit :

> Hi Nicolas.
>
> On Mon, 22 Aug 2011 15:30:06 +0200
> Nicolas Cannasse<[hidden email]>  wrote:
>> You can use this new SPOD version by compiling with -D spod_macro and
>> use the sys.db.* classes
>
> Useful update. One question:
> sys.db.Object does not have sync() function anymore?
> respectively sys.db.Manager does not have doSync()?

We added instead lock() which lock+sync the object in case it's not
already locked.

Nicolas


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

Re: New package sys.db / SPOD changes

Andreas Mokros
Hi.

On Mon, 29 Aug 2011 10:41:12 +0200
Nicolas Cannasse <[hidden email]> wrote:
> We added instead lock() which lock+sync the object in case it's not
> already locked.

I had to call sync() after update() or insert() to update the
object. Do I have to call lock() now?

--
Mockey

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

Re: New package sys.db / SPOD changes

Nicolas Cannasse
Le 29/08/2011 11:15, Andreas Mokros a écrit :
> I had to call sync() after update() or insert() to update the
> object. Do I have to call lock() now?

You're right : sync() is still useful after an insert() in order to make
sure that all Int fields are set to 0 (or their default database value
if you're using this - which is bad idea IMHO). However I fail to see
how it would be useful after and update() ?

Will put it back right now and think again later about it.

Best,
Nicolas

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

Re: New package sys.db / SPOD changes

Nicolas Cannasse
Le 11/09/2011 14:46, Nicolas Cannasse a écrit :
> Le 29/08/2011 11:15, Andreas Mokros a écrit :
>> I had to call sync() after update() or insert() to update the
>> object. Do I have to call lock() now?
>
> You're right : sync() is still useful after an insert() in order to make
> sure that all Int fields are set to 0 (or their default database value
> if you're using this - which is bad idea IMHO). However I fail to see
> how it would be useful after and update() ?

Actually, I made another change : after an insert(), all object fields
which are null (but not nullable) get a default value (int+float = 0,
string="", bytes = haxe.io.Bytes.alloc(0)). This is very similar to a
sync() but does not make any extra DB request.

Best,
Nicolas


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

Re: New package sys.db / SPOD changes

Andreas Mokros
In reply to this post by Nicolas Cannasse
Hi.

On Sun, 11 Sep 2011 14:46:23 +0200
Nicolas Cannasse <[hidden email]> wrote:
> However I fail to see
> how it would be useful after and update() ?

Not sure right now why I needed it. Will think about it, too.

--
Mockey

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

Re: New package sys.db / SPOD changes

Andreas Mokros
In reply to this post by Nicolas Cannasse
Hi.

On Sun, 11 Sep 2011 15:03:53 +0200
Nicolas Cannasse <[hidden email]> wrote:
> Actually, I made another change : after an insert(), all object
> fields which are null (but not nullable) get a default value
> (int+float = 0, string="", bytes = haxe.io.Bytes.alloc(0)). This is
> very similar to a sync() but does not make any extra DB request.

Sounds reasonable, will try it out.

--
Mockey

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