I am trying to build  a datamapper Query dynamically. Most of it works
when I add field, order  but when I use the like, I see something
strange in the query object .. like preallocated memory object... Is
this expected?

a = ApiAccount.all(:created_at => 'asdasd').query

=> #<DataMapper::Query @repository=:default @model=ApiAccount
@fields=[#<DataMapper::Property::String @model=ApiAccount @name=:id>,
#<DataMapper::Property::DateTime @model=ApiAccount @name=:created_at>,
#<DataMapper::Property::DateTime @model=ApiAccount @name=:updated_at>,
#<DataMapper::Property::String @model=ApiAccount @name=:name>,
#<DataMapper::Property::String @model=ApiAccount @name=:description>,
#<DataMapper::Property::String @model=ApiAccount @name=:secret>,
#<DataMapper::Property::String @model=ApiAccount @name=:team_id>,
#<DataMapper::Property::String @model=ApiAccount @name=:board_id>,
#<DataMapper::Property::String @model=ApiAccount @name=:format>,
#<DataMapper::Property::Boolean @model=ApiAccount @name=:enabled>]
@links=[] @conditions=#<DataMapper::Query::Conditions::AndOperation:
0xb6f177a8 @operands=#<Set:
{#<DataMapper::Query::Conditions::EqualToComparison
@subject=#<DataMapper::Property::DateTime @model=ApiAccount
@name=:created_at> @dumped_value="asdasd" @loaded_value="asdasd">}>>
@order=[#<DataMapper::Query::Direction
@target=#<DataMapper::Property::String @model=ApiAccount @name=:id>
@operator=:asc>] @limit=nil @offset=0 @reload=false @unique=false>


Then I do :  a =   a &  ApiAccount.all(:id => 'asdasd').query


=> #<DataMapper::Query @repository=:default @model=ApiAccount
@fields=[#<DataMapper::Property::String @model=ApiAccount @name=:id>,
#<DataMapper::Property::DateTime @model=ApiAccount @name=:created_at>,
#<DataMapper::Property::DateTime @model=ApiAccount @name=:updated_at>,
#<DataMapper::Property::String @model=ApiAccount @name=:name>,
#<DataMapper::Property::String @model=ApiAccount @name=:description>,
#<DataMapper::Property::String @model=ApiAccount @name=:secret>,
#<DataMapper::Property::String @model=ApiAccount @name=:team_id>,
#<DataMapper::Property::String @model=ApiAccount @name=:board_id>,
#<DataMapper::Property::String @model=ApiAccount @name=:format>,
#<DataMapper::Property::Boolean @model=ApiAccount @name=:enabled>]
@links=[] @conditions=#<DataMapper::Query::Conditions::AndOperation:
0xb6f06480 @operands=#<Set:
{#<DataMapper::Query::Conditions::EqualToComparison
@subject=#<DataMapper::Property::String @model=ApiAccount @name=:id>
@dumped_value="asdasd" @loaded_value="asdasd">,
#<DataMapper::Query::Conditions::EqualToComparison
@subject=#<DataMapper::Property::DateTime @model=ApiAccount
@name=:created_at> @dumped_value="asdasd" @loaded_value="asdasd">}>>
@order=[#<DataMapper::Query::Direction
@target=#<DataMapper::Property::String @model=ApiAccount @name=:id>
@operator=:asc>] @limit=nil @offset=0 @reload=false @unique=false>


Finally I add a limit to all of that. Limit is still not set....but
then I see the mnumber of preallocated records..


a = a & ApiAccount.all({:limit => '4').query

 #<DataMapper::Query @repository=:default @model=ApiAccount
@fields=[#<DataMapper::Property::String @model=ApiAccount @name=:id>,
#<DataMapper::Property::DateTime @model=ApiAccount @name=:created_at>,
#<DataMapper::Property::DateTime @model=ApiAccount @name=:updated_at>,
#<DataMapper::Property::String @model=ApiAccount @name=:name>,
#<DataMapper::Property::String @model=ApiAccount @name=:description>,
#<DataMapper::Property::String @model=ApiAccount @name=:secret>,
#<DataMapper::Property::String @model=ApiAccount @name=:team_id>,
#<DataMapper::Property::String @model=ApiAccount @name=:board_id>,
#<DataMapper::Property::String @model=ApiAccount @name=:format>,
#<DataMapper::Property::Boolean @model=ApiAccount @name=:enabled>]
@links=[] @conditions=#<DataMapper::Query::Conditions::AndOperation:
0xb6efa6e4 @operands=#<Set:
{#<DataMapper::Query::Conditions::InclusionComparison
@subject=#<DataMapper::Associations::OneToMany::Relationship:
0xb6efb210 @max=Infinity, @parent_model_name="ApiAccount",
@child_model=ApiAccount, @default=nil, @child_properties=[:id],
@child_repository_name=:default, @min=0,
@instance_variable_name="@self", @name=:self,
@parent_properties=[:id], @parent_model=ApiAccount, @query={},
@writer_visibility=:public,
@options={:parent_repository_name=>:default, :parent_key=>[:id], :min=>0, 
:child_key=>[:id], :max=>Infinity, :child_repository_name=>:default},
@child_model_name="ApiAccount", @reader_visibility=:public,
@parent_repository_name=:default> @dumped_value=[#<ApiAccount
@id="4d3c9b7c-6530-11e0-9e62-000c29ae10f1" @created_at=<not loaded>
@updated_at=<not loaded> @name=<not loaded> @description=<not loaded>
@secret=<not loaded> @team_id=<not loaded> @board_id=<not loaded>
@format=<not loaded> @enabled=<not loaded>>]
@loaded_value=[#<ApiAccount @id="4d3c9b7c-6530-11e0-9e62-000c29ae10f1"
@created_at=<not loaded> @updated_at=<not loaded> @name=<not loaded>
@description=<not loaded> @secret=<not loaded> @team_id=<not loaded>
@board_id=<not loaded> @format=<not loaded> @enabled=<not loaded>>]>,
#<DataMapper::Query::Conditions::EqualToComparison
@subject=#<DataMapper::Property::DateTime @model=ApiAccount
@name=:created_at> @dumped_value="asdasd" @loaded_value="asdasd">}>>
@order=[#<DataMapper::Query::Direction
@target=#<DataMapper::Property::String @model=ApiAccount @name=:id>
@operator=:asc>] @limit=nil @offset=0 @reload=false @unique=false>


Then I could execute the query using

 ApiAccount.all(a)

. How would I add a limite to an

So how would I add to the query Object a limit ? what am I missing?

Emmanuel

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to