Spod macro .delete(condition) compilation error

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

Spod macro .delete(condition) compilation error

Julien CASTETS
Hi,

Following the spod macro documentation (http://haxe.org/doc/neko/spod) I tried to do this

...
SpodTypes.manager.delete(id <= 72);
...

And this cause the following compilation error (targeting neko) with SVN revision 3948
src/Main.hx:73: characters 28-30 : Unknown identifier : id

Is this a bug or something I'm doing wrong ?

PS: 
The same happens with select. 
But works with select(true).
Please also note that select(true) returns only the first row, I thought it should return a List


Best
Julien

package ;
import haxe.macro.Expr;
import haxe.Public;
import php.Sys;
import sys.db.Object;
import sys.db.Types;

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();
}
}

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

Re: Spod macro .delete(condition) compilation error

Andreas Mokros
Hi.

On Mon, 29 Aug 2011 01:41:49 +0200
Julien CASTETS <[hidden email]> wrote:
> SpodTypes.manager.delete(id <= 72);
> And this cause the following compilation error (targeting neko) with
> SVN revision 3948
> src/Main.hx:73: characters 28-30 : Unknown identifier : id

For the new macro SPOD identifiers in expressions must be prefixed with
"$" (recent change):
SpodTypes.manager.delete($id <= 72);

> Please also note that select(true) returns only the first row, I
> thought it should return a List

select always returns one (first) item, search returns a list.

--
Mockey

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

Re: Spod macro .delete(condition) compilation error

Nicolas Cannasse
Le 29/08/2011 09:59, Andreas Mokros a écrit :
>> Please also note that select(true) returns only the first row, I
>> thought it should return a List
>
> select always returns one (first) item, search returns a list.

BTW I'm not that much happy with this naming scheme. Still time to
change if you have a better idea.

Nicolas


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

Re: Spod macro .delete(condition) compilation error

Jason O'Neil-2
The non-macro version of SPOD uses get() [single] and search() [multiple].  Could you keep that naming scheme perhaps?  In my mind "select" is not obviously referring to a single or multiple result.

Jason

On Mon, Aug 29, 2011 at 4:42 PM, Nicolas Cannasse <[hidden email]> wrote:
Le 29/08/2011 09:59, Andreas Mokros a écrit :

Please also note that select(true) returns only the first row, I
thought it should return a List

select always returns one (first) item, search returns a list.

BTW I'm not that much happy with this naming scheme. Still time to change if you have a better idea.

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: Spod macro .delete(condition) compilation error

Nicolas Cannasse
Le 29/08/2011 10:59, Jason O'Neil a écrit :
> The non-macro version of SPOD uses get() /[single]/ and search()
> /[multiple]/.  Could you keep that naming scheme perhaps?  In my mind
> "select" is not obviously referring to a single or multiple result.

get() is reserved for get-by-key right now.
In previous SPOD we had object(SQL) objects(SQL).

Nicolas

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

Re: Spod macro .delete(condition) compilation error

Julien CASTETS
Thank you guys, it just works :)

I got it to work targeting php but I've to test more things before making a patch proposal

BTW I've no good proposal to replace '$' :(

Best
Julien

2011/8/29 Nicolas Cannasse <[hidden email]>
Le 29/08/2011 10:59, Jason O'Neil a écrit :

The non-macro version of SPOD uses get() /[single]/ and search()
/[multiple]/.  Could you keep that naming scheme perhaps?  In my mind
"select" is not obviously referring to a single or multiple result.

get() is reserved for get-by-key right now.
In previous SPOD we had object(SQL) objects(SQL).


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: Spod macro .delete(condition) compilation error

Jason O'Neil-2
In reply to this post by Nicolas Cannasse
Sorry, my misunderstanding, I should have paid better attention to Julien's post.

I think object and objects makes sense, or possibly select (multiple) and selectOne (single) or something similar? 

In fact is there even a need to have a separate function for limiting the results, or could you just use a query with "LIMIT 1" and use select(query).first(); ?

Jason


On Mon, Aug 29, 2011 at 5:38 PM, Nicolas Cannasse <[hidden email]> wrote:
Le 29/08/2011 10:59, Jason O'Neil a écrit :

The non-macro version of SPOD uses get() /[single]/ and search()
/[multiple]/.  Could you keep that naming scheme perhaps?  In my mind
"select" is not obviously referring to a single or multiple result.

get() is reserved for get-by-key right now.
In previous SPOD we had object(SQL) objects(SQL).


Nicolas

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


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