Re: Transactions and paged_each

2016-08-31 Thread Jeremy Evans
On Wednesday, August 31, 2016 at 9:47:52 PM UTC-7, Trevor Turk wrote:
>
> Hello,
>
> I've been reading about paged_each and it seems to work well in my 
> testing, but I'm concerned about using it in production because the 
> documentation says it uses a transaction internally. 
>
> I plan to make a "backfill" script that iterates over all rows in a 
> production database and enqueues background jobs for processing them etc.
>
> Would using paged_each lock the table and prevent my (Sinatra) app from 
> functioning regularly?
>
> Thank you!
> - Trevor
>

Dataset#paged_each shouldn't lock the entire table, as it just selects 
rows, but the behavior in regards to locking depends on the database.  It 
would probably be best for you to try it in a test environment to be sure 
it functions as you expect, before using it in production.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Transactions and paged_each

2016-08-31 Thread Trevor Turk
Hello,

I've been reading about paged_each and it seems to work well in my testing, 
but I'm concerned about using it in production because the documentation 
says it uses a transaction internally. 

I plan to make a "backfill" script that iterates over all rows in a 
production database and enqueues background jobs for processing them etc.

Would using paged_each lock the table and prevent my (Sinatra) app from 
functioning regularly?

Thank you!
- Trevor

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: "delay_add_association" plugin and one_to_one relationship

2016-08-31 Thread Jeremy Evans
On Wednesday, August 31, 2016 at 7:50:48 AM UTC-7, David Espada wrote:
>
> 2016-08-31 16:00 GMT+02:00 Jeremy Evans :
>
>> I suppose that is something I would consider as an addition to 
>> delay_add_association.  Do you want to work on a pull request for it?
>>
>> I have seen lightly the code and... it frightens me a little, but can try 
> it :)
>
> What I wish is having changed behaviour in all cases, when entity is new 
> and when is not. If you assign a related entity in ANY case, persistence  
> and linking is delayed until main (root) entity is persisted. What do you 
> think of that option?
>

That's certainly not the behavior of delay_add_association in the *_many 
association case, so it wouldn't make sense for it to be the default in the 
one_to_one case.  If you want that behavior, you can probably write your 
only plugin, or just do:

  plugin :instance_hooks

  def association=(v)
 after_save_hook{super}
  end 

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: "delay_add_association" plugin and one_to_one relationship

2016-08-31 Thread David Espada
2016-08-31 16:00 GMT+02:00 Jeremy Evans :

> I suppose that is something I would consider as an addition to
> delay_add_association.  Do you want to work on a pull request for it?
>
> I have seen lightly the code and... it frightens me a little, but can try
it :)

What I wish is having changed behaviour in all cases, when entity is new
and when is not. If you assign a related entity in ANY case, persistence
and linking is delayed until main (root) entity is persisted. What do you
think of that option?

Thank you.

-- 
David

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: "delay_add_association" plugin and one_to_one relationship

2016-08-31 Thread Jeremy Evans
On Wednesday, August 31, 2016 at 4:36:40 AM UTC-7, David Espada wrote:
>
> Hi all.
>
> There is a good little Sequel plugin called "delay_add_association" that 
> avoids persistence when adding a child (one_to_many) to an entity. That is 
> good in my
> system, because I like to have a consistent object representation without
> persisting nothing until the end of the work cycle.
>
> But I have a problem for generalizing that behaviour with one_to_one 
> relations.
> In that case I can't do assignation between entities avoiding persistence.
>
> Can we have a similar solution for one_to_one as in one_to_many? I think 
> that
> consistent behaviour is good for Sequel practices :)
>

I suppose that is something I would consider as an addition to 
delay_add_association.  Do you want to work on a pull request for it?

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


"delay_add_association" plugin and one_to_one relationship

2016-08-31 Thread David Espada
Hi all.

There is a good little Sequel plugin called "delay_add_association" that
avoids persistence when adding a child (one_to_many) to an entity. That is
good in my
system, because I like to have a consistent object representation without
persisting nothing until the end of the work cycle.

But I have a problem for generalizing that behaviour with one_to_one
relations.
In that case I can't do assignation between entities avoiding persistence.

Can we have a similar solution for one_to_one as in one_to_many? I think
that
consistent behaviour is good for Sequel practices :)

Thank you very much.

-- 
David

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.