Re: auto_validations plugin: how to disable unique validations on all models

2021-09-02 Thread Jeremy Evans
On Thu, Sep 2, 2021 at 6:30 AM 'petr@me.com' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hey Jeremy, > thank you for your answer. What do you think about this solution? > > Sequel::Model.plugin :subclasses do |sub_class| > sub_class.skip_auto_validations(:unique) > end > Sure,

Re: auto_validations plugin: how to disable unique validations on all models

2021-09-02 Thread 'petr....@me.com' via sequel-talk
com' via sequel-talk < > seque...@googlegroups.com> wrote: > >> Hi, >> how can I disable/skip unique auto validations on all models? >> >> I've tried Sequel::Model.skip_auto_validations(:unique) but it's not >> working... >> > > skip_

Re: auto_validations plugin: how to disable unique validations on all models

2021-09-01 Thread Jeremy Evans
On Wed, Sep 1, 2021 at 6:14 AM 'petr@me.com' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hi, > how can I disable/skip unique auto validations on all models? > > I've tried Sequel::Model.skip_auto_validations(:unique) but it's not > working... > skip_auto_

auto_validations plugin: how to disable unique validations on all models

2021-09-01 Thread 'petr....@me.com' via sequel-talk
Hi, how can I disable/skip unique auto validations on all models? I've tried Sequel::Model.skip_auto_validations(:unique) but it's not working... -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop

Re: Dropping a table does not drop all constraint validations

2019-03-13 Thread 'Mike Pastore' via sequel-talk
On Tuesday, March 12, 2019 at 2:08:01 PM UTC-5, Jeremy Evans wrote: > > Change committed: > https://github.com/jeremyevans/sequel/commit/d198cc1851c7cba380632a35f88ca193c346d6ae > Fantastic news. Thanks Jeremy! Mike -- You received this message because you are subscribed to the Google

Re: Dropping a table does not drop all constraint validations

2019-03-06 Thread Nick Appelmans
ers) and found that the old model name was still being >> referenced when Sequel was working out the associations. Here is part of >> the error message... >> > > It is certainly not related to Mike's issue with constraint validations. > > >> 2019-03-06 17:42:10 - Nam

Re: Dropping a table does not drop all constraint validations

2019-03-06 Thread Jeremy Evans
with the new model name > (auth_users) and found that the old model name was still being referenced > when Sequel was working out the associations. Here is part of the error > message... > It is certainly not related to Mike's issue with constraint validations. > 2019

Re: Dropping a table does not drop all constraint validations

2019-03-06 Thread Nick Appelmans
thoughts, Nick On Saturday, March 2, 2019 at 12:13:16 PM UTC-8, Jeremy Evans wrote: > > On Saturday, March 2, 2019 at 9:58:16 AM UTC-8, Mike Pastore wrote: >> >> Jeremy, >> >> Just to confirm something. It appears that dropping the table :foo does >> not also d

Re: Dropping a table does not drop all constraint validations

2019-03-02 Thread Jeremy Evans
On Saturday, March 2, 2019 at 9:58:16 AM UTC-8, Mike Pastore wrote: > > Jeremy, > > Just to confirm something. It appears that dropping the table :foo does > not also drop all constraint validations for table :foo. So my down > migrations should all look like this: > >

Re: Sequel throwing an error when validations fail

2018-12-02 Thread Jeremy Evans
On Sunday, December 2, 2018 at 2:55:00 PM UTC-8, Steven Garcia wrote: > > Coming from ActiveRecord I was a bit perplexed by Sequel's behavior when > validations fail. > > In a Rails app I could simply run a condition on @model.valid? and keep it > moving. > > But Sequel

Re: Sequel throwing an error when validations fail

2018-12-02 Thread Steven Garcia
Nevermind - figured it out: Sequel::Model.raise_on_save_failure = false Just starting to get the hang of your API ;) Cheers -- 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

Sequel throwing an error when validations fail

2018-12-02 Thread Steven Garcia
Coming from ActiveRecord I was a bit perplexed by Sequel's behavior when validations fail. In a Rails app I could simply run a condition on @model.valid? and keep it moving. But Sequel actually throws an error, which breaks the app - so I find myself doing this: begin @site.update(r.params

Re: Validations: allow errors.add before valid?

2015-07-02 Thread Janko Marohnić
I wanted to do validations outside of the model (so outside of `Sequel::Model#validate`), and then I also found out that #valid? first clears the errors. For me it worked that instead of `#valid?` I just used `errors.empty?`, and it worked great for my case. If you do want to have validations

Re: Validations: allow errors.add before valid?

2015-07-02 Thread James
Thank you, that's a simple solution. On Thursday, July 2, 2015 at 5:06:22 AM UTC-6, Janko Marohnić wrote: I wanted to do validations outside of the model (so outside of `Sequel::Model#validate`), and then I also found out that #valid? first clears the errors. For me it worked that instead

Validations: allow errors.add before valid?

2015-06-05 Thread James
This is sort of a feature request I guess, and something that's caused me to bang my head a few times now. Currently you can access #errors and #errors.add methods on a model, but they're not of any use (that I'm aware of). Any errors added using errors.add() prior to calling valid? will be

Re: Validations: allow errors.add before valid?

2015-06-05 Thread James
A quick example using irb: irb(main):002:0 o = Order.last irb(main):003:0 o.valid? = true irb(main):004:0 o.errors.add(nil, 'Test') = [Test] irb(main):005:0 o.valid? = true irb(main):006:0 On Friday, June 5, 2015 at 3:46:54 PM UTC-6, James wrote: This is sort of a feature request I guess, and

Re: Validations: allow errors.add before valid?

2015-06-05 Thread Jeremy Evans
On Friday, June 5, 2015 at 2:46:54 PM UTC-7, James wrote: This is sort of a feature request I guess, and something that's caused me to bang my head a few times now. Currently you can access #errors and #errors.add methods on a model, but they're not of any use (that I'm aware of). Any

Transactions are not rollback if save fails because of validations and raise_on_save_failure is false

2014-03-31 Thread Deepak Agrawal
These are the models : class User Sequel::Model self.raise_on_save_failure = false end class Addresses Sequel::Model many_to_one: user self.raise_on_save_failure = false end address = Addresses.find(id: 1) user = address.user DB.transaction do address.delete user.save end In

Re: Transactions are not rollback if save fails because of validations and raise_on_save_failure is false

2014-03-31 Thread Jeremy Evans
On Monday, March 31, 2014 7:39:01 PM UTC-7, Deepak Agrawal wrote: These are the models : class User Sequel::Model self.raise_on_save_failure = false end class Addresses Sequel::Model many_to_one: user self.raise_on_save_failure = false end address = Addresses.find(id: 1)

Re: Feedback Request: Constraint Validations

2012-08-29 Thread Michael Lang
rules, as DBMS's have gotten quite good at doing, why trust ruby validations to the job (esp. when they can't prevent scripting mistakes made outside the application's code-base like the database constraints can)? So this is something I'm definitely interested in and will try to take a good look

Re: Feedback Request: Constraint Validations

2012-08-28 Thread Jamie Hodge
Hi Jeremy, First of all, thank you. I'm really happy that you've unified validations and constraints. I found their separation to be a source of bugs and confusion. I've moved a small project over to the current version of the extension/plugin and have three short comments. If you look

Re: Feedback Request: Constraint Validations

2012-08-16 Thread Jeremy Evans
to create database constraints that mirror model validations when creating and altering tables. It adds validation to a separate table. The plugin reads the metadata from that table, and uses it to automatically validate your models before saving. The advantage to doing so is that your

Re: Feedback Request: Constraint Validations

2012-08-15 Thread François Beausoleil
Le 2012-08-14 à 02:07, Christian MICHON a écrit : Hi Jeremy, On Sun, Aug 12, 2012 at 2:39 PM, Christian MICHON christian.mic...@gmail.com wrote: One problem though: using this code, my saved Human object 'Bobby' gets its id = 2, because 1st save did not work: is this the expected

Re: Feedback Request: Constraint Validations

2012-08-14 Thread Christian MICHON
another public branch to GitHub, named consvals. From the commit message: The extension allows you to create database constraints that mirror model validations when creating and altering tables. It adds validation to a separate table. The plugin reads the metadata from that table, and uses

Re: Feedback Request: Constraint Validations

2012-08-14 Thread Jeremy Evans
On Monday, August 13, 2012 11:07:52 PM UTC-7, Christian MICHON wrote: One problem though: using this code, my saved Human object 'Bobby' gets its id = 2, because 1st save did not work: is this the expected behavior? The reason you get id 2 is that it actually tries to do the insert for

Re: Feedback Request: Constraint Validations

2012-08-14 Thread Christian MICHON
On Tue, Aug 14, 2012 at 5:13 PM, Jeremy Evans jeremyeva...@gmail.com wrote: On Monday, August 13, 2012 11:07:52 PM UTC-7, Christian MICHON wrote: One problem though: using this code, my saved Human object 'Bobby' gets its id = 2, because 1st save did not work: is this the expected behavior?

Re: Feedback Request: Constraint Validations

2012-08-12 Thread Christian MICHON
you to create database constraints that mirror model validations when creating and altering tables. It adds validation to a separate table. The plugin reads the metadata from that table, and uses it to automatically validate your models before saving. The advantage to doing so is that your

Re: Feedback Request: Constraint Validations

2012-08-09 Thread Jeremy Evans
On Wednesday, August 1, 2012 12:38:15 PM UTC-7, Jeremy Evans wrote: In a fairly unusual step for Sequel, I have pushed another public branch to GitHub, named consvals. From the commit message: The extension allows you to create database constraints that mirror model validations when

Re: Feedback Request: Constraint Validations

2012-08-06 Thread Iain Barnett
On 1 Aug 2012, at 20:38, Jeremy Evans wrote: In a fairly unusual step for Sequel, I have pushed another public branch to GitHub, named consvals. From the commit message: The extension allows you to create database constraints that mirror model validations when creating and altering

Feedback Request: Constraint Validations

2012-08-01 Thread Jeremy Evans
In a fairly unusual step for Sequel, I have pushed another public branch to GitHub, named consvals. From the commit message: The extension allows you to create database constraints that mirror model validations when creating and altering tables. It adds validation to a separate table

Re: Case insensitivity and unique validations.

2012-07-12 Thread Joe Van Dyk
On Saturday, July 7, 2012 5:25:31 PM UTC-6, cult hero wrote: I've been looking for the best way to deal with that amounts to a case insensitive column in PostgreSQL. (It stores email addresses.) I've found a couple of options (an index using lower() and triggers using lower()) but is there

Case insensitivity and unique validations.

2012-07-07 Thread cult hero
I've been looking for the best way to deal with that amounts to a case insensitive column in PostgreSQL. (It stores email addresses.) I've found a couple of options (an index using lower() and triggers using lower()) but is there some way to make validates_unique do so in an insensitive manner?

Re: nested_attributes and validations on the parent model

2012-06-29 Thread Jack
That makes sense. I'm going with the flag route, since I'd like to keep the validation together and not create one in a before_save block. Thanks Jeremy. -- You received this message because you are subscribed to the Google Groups sequel-talk group. To view this discussion on the web visit

Re: nested_attributes and validations on the parent model

2012-06-29 Thread Jack Chu
Also, I created a gist to test this out. It contains the original problem and an fix implementation using a flag for conditional validation. Maybe someone will find this useful if they run into the same problem. https://gist.github.com/3014816 -- You received this message because you are

nested_attributes and validations on the parent model

2012-06-28 Thread Jack
I have a parent model, Product, that has many Variants. I'm using nested_attributes on the Product model. On the Variants model I have a presence validation on the :product. When I try to persist the product with some :variants_attributes, I get a validation error saying:

Re: nested_attributes and validations on the parent model

2012-06-28 Thread Jeremy Evans
On Thursday, June 28, 2012 5:06:11 PM UTC-7, Jack wrote: I have a parent model, Product, that has many Variants. I'm using nested_attributes on the Product model. On the Variants model I have a presence validation on the :product. When I try to persist the product with some

Re: Validations in Rails 3

2010-03-25 Thread mooman
method. no big deal. On Mar 24, 3:28 pm, Jeremy Evans jeremyeva...@gmail.com wrote: On Mar 24, 12:21 pm, cult hero binarypala...@gmail.com wrote: These are valid points. I guess in that case, I need to figure out how to get Sequel validations to work in line like AM's would for things like forms

Validations in Rails 3

2010-03-24 Thread cult hero
In my previous project I had my own validations system that had carried over as a legacy component. I want to dump that in favor of something in wider use. My question is this: Should I use Sequel's validations or include ActiveModel's in a new project. I'm guessing AM's integrates better

Re: Validations in Rails 3

2010-03-24 Thread Michael Lang
Personally, I would use Sequel's. The Rails API seems to change often on a whim while Sequel breaks backwards compatibility on much rarer occasions. Plus, if implemented right, you can invest your business logic in your models and maintain easy portability to other systems. Right now, I have one

Something I've always wished for: validations before any arbitrary model method

2009-10-15 Thread Nate Wiger
So this isn't really supported by other ORM's and I can't find a match in the Sequel rdoc for validations, so it's probably not supported. But maybe there's a way to accomplish this. One thing I've always wanted is class-level validation hooks that can specify an arbitrary method name to run

Re: Something I've always wished for: validations before any arbitrary model method

2009-10-15 Thread Jeremy Evans
On Oct 15, 7:44 pm, Nate Wiger nwi...@gmail.com wrote: So this isn't really supported by other ORM's and I can't find a match in the Sequel rdoc for validations, so it's probably not supported. But maybe there's a way to accomplish this. One thing I've always wanted is class-level validation

questions about validations

2008-05-26 Thread dusty
Is there an :if option available with validations? I am trying to reproduce the restful_authentication plugin to work with sequel and using something like this. attr_accessor :password validates_presence_of :password, :if = :password_required? protected def password_required

Re: questions about validations

2008-05-26 Thread dusty
Ok, thanks. I'll give not_naughty a shot! Funny name :) On May 26, 11:28 am, Jeremy Evans [EMAIL PROTECTED] wrote: On May 26, 8:20 am, dusty [EMAIL PROTECTED] wrote: Is there an :if option available with validations?  I am trying to reproduce the restful_authentication plugin to work

Re: questions about validations

2008-05-26 Thread Jeremy Evans
On May 26, 8:20 am, dusty [EMAIL PROTECTED] wrote: Is there an :if option available with validations? I am trying to reproduce the restful_authentication plugin to work with sequel and using something like this. attr_accessor :password validates_presence_of :password

Validations and create_before

2008-05-08 Thread Farrel
What's the suggested way to specify a 'validates_presence_of :attr' validation where 'attr' is set in the before_create block? save returns false and says that 'attr' is not set save! works, no exceptions thrown, but I would prefer to use save. Farrel

Re: Validations and create_before

2008-05-08 Thread Farrel
On May 8, 11:33 am, Farrel [EMAIL PROTECTED] wrote: What's the suggested way to specify a 'validates_presence_of :attr' validation where 'attr' is set in the before_create block? save returns false and says that 'attr' is not set save! works, no exceptions thrown, but I would prefer to use

Re: Validations and create_before

2008-05-08 Thread Jeremy Evans
On May 8, 5:03 am, Farrel [EMAIL PROTECTED] wrote: On May 8, 11:33 am, Farrel [EMAIL PROTECTED] wrote: What's the suggested way to specify a 'validates_presence_of :attr' validation where 'attr' is set in the before_create block? save returns false and says that 'attr' is not set save!

Re: Validations

2008-04-18 Thread Florian Aßmann
I can't actually find it. SourceForge or did you mean RubyForge where I can't find the patch either... :/ Am 18.04.2008 um 23:10 schrieb Uzytkownik: On Apr 17, 8:39 am, Florian Aßmann [EMAIL PROTECTED] wrote: Hi Uzytknownik, If you provide attribute names on builder invokation you only

Validations

2008-04-14 Thread Uzytkownik
May I ask is it possible to use conditional validation in new Sequel? I cannot find it neighter working nor in assistance documentation (I can in validatable documentation, which sequel seems to use no more). Regards --~--~-~--~~~---~--~~ You received this

Re: Validations

2008-04-14 Thread Aman Gupta
You can try the not_naughty plugin for validations: http://groups.google.com/group/sequel-talk/browse_frm/thread/7ca5e048f427e829/978bfc9b8b71b82d?hl=enlnk=gstq=not_naughty#978bfc9b8b71b82d On Apr 14, 9:50 am, Uzytkownik [EMAIL PROTECTED] wrote: May I ask is it possible to use conditional

Re: Validations

2008-04-14 Thread Uzytkownik
On Apr 14, 6:53 pm, Aman Gupta [EMAIL PROTECTED] wrote: You can try the not_naughty plugin for validations: http://groups.google.com/group/sequel-talk/browse_frm/thread/7ca5e048... Thanks --~--~-~--~~~---~--~~ You received this message because you

Re: validations using assistance 0.1.4

2008-02-16 Thread winston
great!! =) is there any place that i can log future bugs? thanks! On Feb 16, 4:02 pm, Sharon Rosner [EMAIL PROTECTED] wrote: In my model, I tried to put each in the validates block, but this would generate errors on running spec. However, if I place the each clause outside the validates

Re: validations using assistance 0.1.4

2008-02-16 Thread Tim Uckun
This was a bug in the assistance gem. I pushed out a new release so it should be available in a few hours. Would this also fix my poblem? The following code using ADO fails. db = Sequel.ado 'db_name', :user = 'sa', :password = 'some_pwd', :host = 'my_computer_name' sql = 'select top 1 *

Re: new validations implementation

2008-01-19 Thread Zack Chandler
After some further thought I'm rewriting the whole thing again and will also build an errors class. you'll probably see a solution later today. Sharon, Two things that would be great to see as you rewrite validations are: 1) Make update(...) check for validations like save(...) 2

Re: new validations implementation

2008-01-18 Thread Sharon Rosner
def errorify_field(attrs, col)   attrs.add_html_class!(error) if @_obj.respond_to?(:errors) @_obj.errors.on(col) end After some further thought I'm rewriting the whole thing again and will also build an errors class. you'll probably see a solution later today. best sharon

Re: new validations implementation

2008-01-18 Thread Zack Chandler
After some further thought I'm rewriting the whole thing again and will also build an errors class. you'll probably see a solution later today. Sharon, I look forward to the new version! Zack --~--~-~--~~~---~--~~ You received this message because you are

Re: new validations implementation

2008-01-17 Thread Zack Chandler
On Jan 16, 2008 4:16 AM, Sharon Rosner [EMAIL PROTECTED] wrote: hi everybody the new validations implementation is in the trunk, so please give it a whirl. i've tried to follow the validation specs as implemented in ActiveRecord, rather than the validatable gem which is incomplete and even

Re: Sequel::Model validations saving

2008-01-15 Thread jrmy
I would see the sequel-model class having a base set of validations that are all performed on the code side. Then each database plugin can somehow override this base set to provide validation from the database. This would allow people to switch between databases without any changes to their code

Re: Sequel::Model validations saving

2008-01-15 Thread Sharon Rosner
I'm curious about what seems to be a current state of saving a model with validations.  Right now it seems that obj.save will save the object to the database regardless of whether or not it passes validations.  I would like to know if this is the intended behavior. Right now

Re: Sequel::Model validations saving

2008-01-15 Thread David Lee
Errors are, as you say, database-specific. However, we already do have database specific code, so it won't be causing any portability issues that were not there in the first place. That said, perhaps the simplest way of getting this started is to implement the database_validates_constraint

Re: Sequel::Model validations saving

2008-01-15 Thread Sharon Rosner
model side to keep all that model logic in one place. Meh, I don't have a good idea on how to solve that one. I think validations should be separate from constraints. Those are really two different things with different capabilities. I really don't see the connection between them, and IMO there's

Re: Sequel::Model validations saving

2008-01-15 Thread David Lee
Hey Jeremy, On Jan 15, 8:28 am, jrmy [EMAIL PROTECTED] wrote: I would see the sequel-model class having a base set of validations that are all performed on the code side. Then each database plugin can I agree. There are certain validations that can only be performed client side. However

Re: Sequel::Model validations saving

2008-01-15 Thread Zack Chandler
On Jan 15, 2008 8:38 AM, Sharon Rosner [EMAIL PROTECTED] wrote: I'm curious about what seems to be a current state of saving a model with validations. Right now it seems that obj.save will save the object to the database regardless of whether or not it passes validations. I would like

Re: Sequel::Model validations saving

2008-01-15 Thread Zack Chandler
model. It seems to me that the constraints need to be somehow defined model side to keep all that model logic in one place. Meh, I don't have a good idea on how to solve that one. I think validations should be separate from constraints. Those are really two different things with different

Re: Sequel::Model validations saving

2008-01-15 Thread David Lee
Once again, I'm not saying we should support constraints WITHIN the model. Let me state my assumptions: - validations exist to give users a nice error message to prevent models from being saved, because otherwise, the database will raise a nasty error - validations do not validate 100

Re: Sequel::Model validations saving

2008-01-15 Thread Joe
Wow, I didn't mean to uncork a can of worms on this one, I hope it got as sorted out as it appears to be. If I understand this correctly, I can expect to see a .save .save! methods appear in sequel_model, as well as changes to the validations so that some validations are done based on the model

Re: Sequel::Model validations saving

2008-01-14 Thread Lance Carlson
I'm going to look at validations soon and do some refactoring. I will also look into this problem. You could instead of saving, check for errors before saving. however it seems more ideal for the object to keep track of its own state in this case. -Lance On Jan 14, 2008 5:59 PM, Joe [EMAIL

Re: Sequel::Model validations saving

2008-01-14 Thread David Lee
I wish validations were tightly integrated into the database. Validations are something that ActiveRecord was not good at. For example, validating uniqueness or presence of an associated object would actually not enforce validation (under rare race conditions). This is because it is impossible

Re: Sequel::Model Validations

2008-01-03 Thread Lance Carlson
I'm not exactly sure what you are trying to accomplish. there is a validates_uniqueness_of :column also I believe you can group validations.. though we should pretty this syntax up. Look how this is accomplished using the validatable gem. This is subject to change in the future. Perhaps a combo

Re: Sequel::Model Validations

2007-12-22 Thread Lance Carlson
Some subtle design refactorings: we should change validations validates so the block looks like this: validates do format_of :name, etc. presence_of :name end Also validations is a class method in validatable :). Wayne and I are refactoring right now. Also a :with_options hash might