How to Disable Inflections?

2011-11-16 Thread Tom Wardrop
One thing that drives me nuts with a lot of Ruby libraries and frameworks is pluralization, it's a good example of probably the one thing about the Ruby community that annoys me the most, and that's the tendency to sacrifice function/practicality in favor of prettiness. If I want my class name to d

Re: How to Disable Inflections?

2011-11-16 Thread Tom Wardrop
Thanks Jeremy. Tom On Nov 16, 9:26 pm, Jeremy Evans wrote: > On Nov 16, 5:03 am, Tom Wardrop wrote: > > > One thing that drives me nuts with a lot of Ruby libraries and > > frameworks is pluralization, it's a good example of probably the one > > thing about the

How to Run Migration In-Code?

2011-11-21 Thread Tom Wardrop
I've got a directory that contains all my migrations using the format xxx_migration_description.rb. They of course work using the sequel command line tool. I'm wondering though, is there a simple way I can run/call these migrations from within ruby. As part of spec setup in my spec_helper.rb file,

Re: How to Run Migration In-Code?

2011-11-22 Thread Tom Wardrop
Awesome, I knew it'd be simply a matter of finding the appropriate method call (I already knew about "Sequel.extension :migration"). Thanks On Nov 22, 6:24 pm, Christian MICHON wrote: > On Tue, Nov 22, 2011 at 7:59 AM, Tom Wardrop wrote: > > > I've got

Sequel Should Be Friendlier Toward Singular Table Names

2012-02-05 Thread Tom Wardrop
In our organisation, we've decided that table names should be singular, i.e. they should represent the objects/rows they store, rather than refer to the collection as a whole. So instead of having a People table, we'd have a Person table. It can simplify the code as well, as you don't need to remem

Re: Sequel Should Be Friendlier Toward Singular Table Names

2012-02-06 Thread Tom Wardrop
ase class from Sequel::Model, or is there a better way? Cheers On Feb 6, 5:05 pm, Tom Wardrop wrote: > In our organisation, we've decided that table names should be > singular, i.e. they should represent the objects/rows they store, > rather than refer to the collection as a w

Re: Sequel Should Be Friendlier Toward Singular Table Names

2012-02-06 Thread Tom Wardrop
As always, plenty thanks Jeremy. Tom On Feb 7, 4:14 am, Jeremy Evans wrote: > On Feb 6, 4:34 am, Tom Wardrop wrote: > > > > > > > > > > > In the mean time, to get this fixed so I can move on, I'd like to sub- > > class Sequel::Model into somethin

Suggestions for Improvement

2012-03-27 Thread Tom Wardrop
I just have a couple of suggestions for Sequel that I'd like to get some community feedback on, hopefully getting a bit of weight behind them so there's less debate over implementing these changes. 1) I believe #length should be added to Sequel::Dataset as an alias of #count / #size? My rationa

Re: Suggestions for Improvement

2012-03-28 Thread Tom Wardrop
01:42:33 UTC+10, Jeremy Evans wrote: > > On Tuesday, March 27, 2012 4:26:37 AM UTC-7, Tom Wardrop wrote: >> >> I just have a couple of suggestions for Sequel that I'd like to get some >> community feedback on, hopefully getting a bit of weight behind them so >>

Re: Suggestions for Improvement

2012-03-28 Thread Tom Wardrop
;> shouldn't be treated as Arrays. >> >> RE: the validation, I've no opinion. I don't tend to use the validations. >> >> On Tuesday, March 27, 2012 7:26:37 AM UTC-4, Tom Wardrop wrote: >>> >>> I just have a couple of suggestions for S

How to get array of hashes from Sequel::Model dataset

2016-08-23 Thread Tom Wardrop
I feel I'm missing something obvious here. How do I get an array of hashes from a model? The closest I could find is `to_hash`, but is there any way I can get all the results as an array of hashes instead of an array of model instances? Below are examples of #all, #to_hash and my imaginary #to_

Re: How to get array of hashes from Sequel::Model dataset

2016-08-23 Thread Tom Wardrop
Ah, and as soon as I post the question, I find the answer. I'm annoyed because I've used `naked` heaps in previous projects. It's just been a while I suppose *palm to forehead* MyModel.naked.all On Wednesday, 24 August 2016 16:15:23 UTC+10, Tom Wardrop wrote: > > I feel

How to make model read-only?

2016-09-29 Thread Tom Wardrop
Is it possible to make a Model, either at the class or instance level (preferrably class) read-only? Well, of course it's possible, so maybe I should ask, what's the best method of doing this, e.g. a #validate method that always return false, a before_save hook that throws an exception? Thanks,

Re: How to make model read-only?

2016-09-29 Thread Tom Wardrop
Maybe read-only is the wrong word. I basically just want to prevent changes from being saved. #freeze may be a step too far as I don't necessarily care if the data changes, as long as it's not committed to the database. On Friday, 30 September 2016 09:39:41 UTC+10, Tom Wardrop wrote:

Re: How to make model read-only?

2016-09-29 Thread Tom Wardrop
ave a consistent API with the bookings actually stored in the database. On Friday, 30 September 2016 11:37:35 UTC+10, Jeremy Evans wrote: > > On Thursday, September 29, 2016 at 4:41:22 PM UTC-7, Tom Wardrop wrote: >> >> Maybe read-only is the wrong word. I basically just want to p

Best way to dynamically merge together many OR conditions

2016-12-05 Thread Tom Wardrop
So, I have an of values. I want a query that ends up looking something like... SELECT * FROM blah WHERE baz LIKE '' OR baz LIKE '' or baz LIKE '' ... or baz LIKE '' What's the best way to go about this? One idea to loop over the array using #inject and or'ing (`|`) Sequel#like conditions togeth

Re: Best way to dynamically merge together many OR conditions

2016-12-05 Thread Tom Wardrop
I'm thinking perhaps there's a way I can pass an array of Sequel#like conditions to Sequel#or, but my attempts thus far haven't worked out. On Tuesday, 6 December 2016 13:59:29 UTC+10, Tom Wardrop wrote: > > So, I have an of values. I want a query that ends up look

Re: Best way to dynamically merge together many OR conditions

2016-12-06 Thread Tom Wardrop
Thanks Jeremy, that's exactly what I'm looking for :) Tom On 6 Dec 2016 6:05 PM, "Jeremy Evans" wrote: On Monday, December 5, 2016 at 7:59:29 PM UTC-8, Tom Wardrop wrote: > > So, I have an of values. I want a query that ends up looking something > like... > &g

Re: Issue with automatic reconnection

2017-07-12 Thread Tom Wardrop
Why is it that I never find the answer I'm after before posting, but then find it immediately after I post: https://groups.google.com/forum/#!topic/sequel-talk/AE8EfF5wSJU I assume that's the way to go. On Thursday, 13 July 2017 12:25:39 UTC+10, Tom Wardrop wrote: > > He

Issue with automatic reconnection

2017-07-12 Thread Tom Wardrop
Hey Guys, I've finally got to the bottom of a bit of a weird issue. The issue was that if the database connection was interrupted, say because the SQL server had to reboot for updates overnight, I'd have to restart my app due to user session issues, despite the fact that Sequel was automaticall

Re: Issue with automatic reconnection

2017-07-12 Thread Tom Wardrop
July 2017 12:26:43 UTC+10, Tom Wardrop wrote: > > Why is it that I never find the answer I'm after before posting, but then > find it immediately after I post: > https://groups.google.com/forum/#!topic/sequel-talk/AE8EfF5wSJU > > I assume that's the way to go. >

Getting model with association as hash

2017-08-21 Thread Tom Wardrop
This should be relatively trivial, but I'm having trouble working this out. I have two models with a one_to_one relationship, one is "property" and the other "owner". How would I get the following out of Sequel? [ {property_id: 1, baz: "blah", owner: {name: "John", postal_address: "5 Archer S

Re: Getting model with association as hash

2017-08-22 Thread Tom Wardrop
uot;blah", owner: {name : "John", postal_address: "5 Archer St, Downtown VG 3533"}} On Tuesday, 22 August 2017 12:01:29 UTC+10, Jeremy Evans wrote: > > On Monday, August 21, 2017 at 6:00:44 PM UTC-7, Tom Wardrop wrote: >> >> This should be relatively triv

Re: Getting model with association as hash

2017-08-22 Thread Tom Wardrop
I'm basically after something like #to_json, but which obviously returns a standard Ruby hash instead of a JSON string. #to_json allows you to easily :include associations and other fields. Is there anything like that for Ruby hashes? On Wednesday, 23 August 2017 09:36:56 UTC+10, Tom Wa

Re: Sequel 5.0.0 Released

2017-09-07 Thread Tom Wardrop
Thanks Jeremy. Been using Sequel for aa number of years now. I've never seen such a well maintained and professionally developed gem as Sequel. It certainly instils confidence as a user. On Saturday, 2 September 2017 11:18:59 UTC+10, Jeremy Evans wrote: > > Sequel 5.0.0 has been released! > > =

Sequel not upcase'ing column names when using `rename_column`

2018-02-04 Thread Tom Wardrop
Not sure if this a bug, but check the following: # Adds column "TEST" to "RESOURCE" table. add_column :resource, :test, :bit # Renames "TEST" to "another_test" in lower case rename_column :resource, :test, :another_test This is using the TinyTDS adapter. Adding columns automatically converts co

Re: Sequel not upcase'ing column names when using `rename_column`

2018-02-04 Thread Tom Wardrop
Ok, that all makes sense at least. Cheers. On Monday, 5 February 2018 14:51:47 UTC+10, Jeremy Evans wrote: > > On Sunday, February 4, 2018 at 5:32:47 PM UTC-8, Tom Wardrop wrote: >> >> Not sure if this a bug, but check the following: >> >> # Adds column "TEST&