Re: Initialize a Sequel Database from Pg::Connection

2019-04-24 Thread Jeremy Evans
On Wednesday, April 24, 2019 at 7:51:59 AM UTC-7, My Nguyen wrote: > > Hi Jeremy, > We are migrating away from ActiveRecord in our Rails app, and we are > running into issues with transactional fixture in our tests. We think the > problem can be solved by sharing the same connection between

Re: MySQL2#server_version and MariaDB

2019-04-22 Thread Jeremy Evans
On Monday, April 22, 2019 at 6:44:36 AM UTC-7, Василий Колесников wrote: > > Hi! Met some strange behavior when using Sequel with mysql2 driver for > MariaDB server. > > My server says: > > mysql> select version()\G > *** 1. row *** > version():

Re: Logo

2019-04-19 Thread Jeremy Evans
On Saturday, April 20, 2019 at 6:46:09 AM UTC+9, Adriano Tirloni wrote: > > Hi, I recreated it in illustrator. .ai, .svg and .png files inside the > zip. Hope it helps. > Thank you very much for your work on this. It is great to have an svg version of the logo. Thanks, Jeremy -- You

Re: Logo

2019-04-19 Thread Jeremy Evans
On Saturday, April 20, 2019 at 12:40:03 AM UTC+9, Silviu Panaite wrote: > > No SVG, but a 4x enlarged version using waifu2x > . > Awesome, thank you. I was not aware of waifu2x, the results are very impressive. Thanks, Jeremy -- You received this message

Re: Logo

2019-04-19 Thread Jeremy Evans
On Friday, April 19, 2019 at 11:53:05 AM UTC+9, Craig Buchek wrote: > > Is there a larger version of the logo that I can find somewhere? I'm > giving a talk at RailsConf, and will be talking about alternatives to > Active Record. I grabbed the logo from the web site, but it doesn't look > very

Re: Best Way to Serialize Models to Arrays/Hashes for JSON API

2019-04-18 Thread Jeremy Evans
On Friday, April 19, 2019 at 2:09:02 AM UTC+9, shreko wrote: > > I tried that and while it works for the elements of the array of :job > records, I still have a problem not getting associated records :job_items > > @rs[:jobs] = Job.where(:id => [100254,100255]).eager(:job_items).all. >

Re: Best Way to Serialize Models to Arrays/Hashes for JSON API

2019-04-18 Thread Jeremy Evans
On Friday, April 19, 2019 at 12:12:39 AM UTC+9, shreko wrote: > > I like to use roda's :json plugin for sending JSON API Data where we just > send Array/Hash as output of a route. But, in order to take advantage of > Sequel Models and associations, I end up with arrays of models and >

Suggestion on how to use Sequel with extensions tables

2019-04-18 Thread Jeremy Evans
You may want to consider using associations for the external tables. That would probably simplify the code: many_to_one :assoc1 def external_field assoc1&.field end Hopefully that is good enough example. I'm on my phone at RubyKaigi and can't currently provide a more complete example.

Re: Calling Sequel::Dataset#empty? twice results in two queries. Is there a way to cache it?

2019-04-16 Thread Jeremy Evans
On Wednesday, April 17, 2019 at 6:23:49 AM UTC+9, Ryan Kingston wrote: > > I am using Sequel in a Rails view. If I call Sequel::Dataset#empty? twice > in the same view, it results in two queries to the database. Is this the > intended behavior or is there a way to have Sequel cache these kind of

Re: How to save in memory SQLite instance to File?

2019-04-16 Thread Jeremy Evans
On Wednesday, April 17, 2019 at 4:38:56 AM UTC+9, fake farm wrote: > > Greetings friends, > I'm following the readme: > > > DB = Sequel.sqlite > DB.create_table :items do; end > # added a few items > > > > How do I save that in to a local file, like *itemsDB.sqlite* > > > I tried DB.dump,

Re: association_dependencies plugin with sequel-paranoid behaviour

2019-04-08 Thread Jeremy Evans
On Monday, April 8, 2019 at 1:52:20 PM UTC-7, Chris Elsworth wrote: > > Hi Jeremy, > > The problem is the soft deletion needs to happen in the many_to_many join > table. I'm not sure if I can get access to that table in the before_destroy > method? > > Just to make this clear, what I currently

Re: DatabaseDisconnectError

2019-04-08 Thread Jeremy Evans
On Monday, April 8, 2019 at 1:22:48 PM UTC-7, James Silberbauer wrote: > > > On 2019/04/08 20:51, Jeremy Evans wrote: > > On Monday, April 8, 2019 at 6:57:50 AM UTC-7, Gustavo Sobral wrote: >> >> Hi, >> >> I have a Sinatra app with Sequel and Postgres ada

Re: DatabaseDisconnectError

2019-04-08 Thread Jeremy Evans
On Monday, April 8, 2019 at 6:57:50 AM UTC-7, Gustavo Sobral wrote: > > Hi, > > I have a Sinatra app with Sequel and Postgres adapter running in a Phusion > Passenger server and I'm facing around 50~60 > Sequel::DatabaseDisconnectError exceptions a day. These exceptions have > mainly three

Re: association_dependencies plugin with sequel-paranoid behaviour

2019-04-08 Thread Jeremy Evans
On Monday, April 8, 2019 at 6:11:21 AM UTC-7, Chris Elsworth wrote: > > Hello! > > I've inherited a schema which is in a live app that makes heavy use of > "paranoid" behaviour; that is to say it has `deleted_at` columns in just > about every table, including join tables. I'm using the

Re: Any way to replace placeholders in a string of SQL without creating a throw-away dataset?

2019-04-04 Thread Jeremy Evans
On Thursday, April 4, 2019 at 5:46:34 PM UTC-7, vais wrote: > > Hi sequel-talk, > > > What’s the simplest way in Sequel to transform an SQL string containing > placeholders into a string with those placeholders substituted with the > appropriate values? > > > So far the only way I managed to

Re: Multiple where conditions with AND and OR

2019-04-02 Thread Jeremy Evans
On Tuesday, April 2, 2019 at 2:06:36 PM UTC-7, Elanor Riley wrote: > > I need to add multiple where statements, linked with AND, but also include > a where statement with several conditions linked by OR > > What I want to generate: > > SELECT column1, column2 FROM table1 > WHERE item_id IN

Sequel 5.19.0 Released

2019-04-02 Thread Jeremy Evans
Sequel 5.19.0 has been released! = New Features * A Database#rename_enum_value method has been added to the pg_enum extension. It is supported on PostgreSQL 10+: DB.rename_enum_value(:enum_type, 'old_name', 'new_name') = Other Improvements * The performance of row fetching and type

Re: group by instead of distinct

2019-04-02 Thread Jeremy Evans
On Tuesday, April 2, 2019 at 12:42:55 AM UTC-7, mpa...@largus.fr wrote: > > Hi, > > > I want to be able to use group_by instead of distinct in those situations : > > many_to_many :models, > join_table: :submodels, > distinct: :on > > many_through_many :makes, >

Re: Invalid server_version result?

2019-03-25 Thread Jeremy Evans
On Monday, March 25, 2019 at 4:47:02 AM UTC-7, Timothy Kovalev wrote: > > [11] pry(main)> DB.server_version > > => 110002 > > [12] pry(main)> DB['select version()'].first > > => {:version=>"PostgreSQL 11.2 on x86_64-apple-darwin18.2.0, compiled by > Apple LLVM version 10.0.0

Re: Sharding and adding new servers dynamically

2019-03-23 Thread Jeremy Evans
On Saturday, March 23, 2019 at 4:59:07 PM UTC-7, underadying...@gmail.com wrote: > > So, I'm using sharding to provide multi-tenancy to my application with > each customer getting their own database and a shared api pool that will > listen to a message queue to add connections to the pool as

Re: Need help with sql select to weed out duplicates in groups

2019-03-15 Thread Jeremy Evans
On Friday, March 15, 2019 at 7:06:38 PM UTC-7, Scott CL Himmelrich wrote: > > I have a table that I need to select all fields and then group where three > of the fields are the same (sample below Col1, Col2, Col3). Group the > unique combinations of the three fields. If there is only one

Re: Showing full SQL query in error message

2019-03-11 Thread Jeremy Evans
On Monday, March 11, 2019 at 5:11:44 AM UTC-7, Janko Marohnić wrote: > > Hello, > > I have the following problem: whenever an error is raised due to an > invalid SQL query, e.g: > > DB[:table].select(:col1).order(:col2).group(:col3).where(col4: :col5).all > > the error message only shows part

Re: NULL values in where clause unexpected behavior | Sequel with TinyTds

2019-03-07 Thread Jeremy Evans
On Thursday, March 7, 2019 at 4:04:28 AM UTC-8, Quackerjack wrote: > > In addition `.exclude` is also not working: > > irb(main):045:0> DB_OVS[:xxx].exclude(ausleuchtung_vorhanden: "ja").count > => 17 > irb(main):046:0> DB_OVS[:xxx].exclude(ausleuchtung_vorhanden: "ja").sql > => "SELECT * FROM

Re: NULL values in where clause unexpected behavior | Sequel with TinyTds

2019-03-07 Thread Jeremy Evans
On Thursday, March 7, 2019 at 3:54:46 AM UTC-8, Quackerjack wrote: > > Hi Jeremy, > > i ran in following situation on a MS SQL Database (tiny_tds adapter used): > > irb(main):036:0> DB_OVS[:xxx].where(ausleuchtung_vorhanden: nil).count > => 61 > irb(main):038:0>

Re: Dropping a table does not drop all constraint validations

2019-03-06 Thread Jeremy Evans
On Wednesday, March 6, 2019 at 10:42:21 AM UTC-8, Nick Appelmans wrote: > > I don't know if this is relevant or I should make a separate post for this > topic but just in case it is: I renamed a model (AuthUser to Auth_user), > dropped the table (authusers), recreated the table with the new

Re: Adding support associations through other associations

2019-03-02 Thread Jeremy Evans
On Saturday, March 2, 2019 at 10:27:52 AM UTC-8, Kenaniah Cerny wrote: > > Hi Jeremy (et al.), > > I have some code that I would like to contribute back upstream that allows > for associations to be created `:through` other associations, even > recursively. This concept would allow, for example,

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: > > down do >

Re: Foreign key association: Am I doing this correctly?

2019-03-01 Thread Jeremy Evans
On Friday, March 1, 2019 at 3:37:16 PM UTC-8, Nick Appelmans wrote: > > Hello Sequel developers. > > I have three models; Member, Auth_user and Log. A log entry will be made > by an Auth_user about a Member. The Auth_user is a member with special > privileges (password, etc). See the model and

Sequel 5.18.0 Released

2019-03-01 Thread Jeremy Evans
Sequel 5.18.0 has been released! = New Features * A throw_failures plugin has been added for throwing ValidationFailed and HookFailed exceptions instead of raising them. This can improve performance by up to 10x on JRuby and 10-15% on CRuby. However, you would need to modify your

Re: How can I write a custom class, that groups some fields of a table?

2019-02-28 Thread Jeremy Evans
On Thursday, February 28, 2019 at 11:36:16 AM UTC-8, Dimitri Pekarovsky wrote: > > Hi, all. > > I have my custom class for Money, that have exactly 3 fields. I want to > save it to table, say :transactions, where I want to have fields like > :money_amount, :money_currency, :money_exp. > > So

Re: Calling any? on a Sequel Dataset should limit the dataset.

2019-02-27 Thread Jeremy Evans
On Wednesday, February 27, 2019 at 1:17:45 PM UTC-8, p...@affinity.co wrote: > > Calling `empty?` on a Sequel::Dataset adds a `LIMIT 1` to the query, but > calling `any?` does not. > > Was explicitly adding this functionality merely overlooked or is there a > specific reason why `any?` does not

Re: Having trouble with prepared statements when using ruby array of values (JRuby 1.7.26 / Sequel 5.12.0)

2019-02-26 Thread Jeremy Evans
On Tuesday, February 26, 2019 at 1:28:07 PM UTC-8, Ho Gi Hung wrote: > > Howdy. I've been asked to optimize how our app does DB calls to use bound > variables. For things that only need a single string this have been farily > easy/straight forward. However I'm having issues when trying to

Re: Issue with association_proxies plugin after upgrading to Ruby 2.5.4

2019-02-22 Thread Jeremy Evans
On Friday, February 22, 2019 at 3:59:03 PM UTC-8, Barbara Carradini wrote: > > I'm attempting to upgrade from Ruby 2.3.8 to Ruby 2.5.4, but have > encountered and issue with the association_proxies plugin since upgrading: > > *Environment:* > > ruby 2.5.4 > sequel 5.4.0 > sequal_pg 1.11.0 > >

Re: Creating a table with a primary_key does not create a sequence on postgresql

2019-02-22 Thread Jeremy Evans
On Friday, February 22, 2019 at 8:51:22 AM UTC-8, Martinos wrote: > > I have a migration as such: > > Sequel.migration do > change do > create_table(:CDR, :ignore_index_errors => true) do >primary_key :id, :type => "bigint", :keep_order => true > end > end > end > > When I run

Re: Get the batch of rows when using fetch_rows

2019-02-20 Thread Jeremy Evans
On Wednesday, February 20, 2019 at 10:55:28 AM UTC-8, Jeremy Evans wrote: > > On Wednesday, February 20, 2019 at 10:04:52 AM UTC-8, > emmanuel.del...@jobteaser.com wrote: >> >> It is exactly what I want but the previous example returns the following >> error: >&g

Re: Get the batch of rows when using fetch_rows

2019-02-20 Thread Jeremy Evans
On Wednesday, February 20, 2019 at 10:04:52 AM UTC-8, emmanuel.del...@jobteaser.com wrote: > > It is exactly what I want but the previous example returns the following > error: > LocalJumpError: no block given (yield) > from >

Re: Get the batch of rows when using fetch_rows

2019-02-20 Thread Jeremy Evans
On Wednesday, February 20, 2019 at 9:35:59 AM UTC-8, emmanuel.del...@jobteaser.com wrote: > > Hi > > I'm using Sequel with PostgreSQL. > > I want to index each row of my table into an elasticsearch index. > I want to execute bulk index on elasticsearch to minimize the number of > request. > > >

Re: nested_attributes + STI

2019-02-18 Thread Jeremy Evans
On Monday, February 18, 2019 at 7:24:57 AM UTC-8, Benjamin Hutton wrote: > > Currently, I am re-defining #nested_attributes_create in my Resource > class, changing that one line to this: > > obj = if reflection.associated_class == Blocks::Base > attributes[:type].constantize.new > I

Re: Eager with specific (non-default) server

2019-02-12 Thread Jeremy Evans
On Tuesday, February 12, 2019 at 2:12:51 PM UTC-8, Alexander Popov wrote: > > Here are a couple ways you could work around it: >> > > Thank you for work-arounds. > > It is possible in a future version of Sequel we could automatically set a >> server on the eager dataset based on the server of

Re: Eager with specific (non-default) server

2019-02-12 Thread Jeremy Evans
On Tuesday, February 12, 2019 at 1:14:18 PM UTC-8, Alexander Popov wrote: > > Hello! > > I have problems, and I think, it can be resolved in Sequel: > > The query like this works correctly: > > Artist.eager_graph(:albums).server(:replica).all > > But with regular `eager` it fails. I think, because

Re: Using CTE within a WHERE clause

2019-02-11 Thread Jeremy Evans
On Monday, February 11, 2019 at 12:40:35 PM UTC-8, Matthew Schoolmaster wrote: > > Hello- > > I have a straight forward many_to_one relationship and am using the > rcte_tree plugin as follows: > > class Item < Sequel::Model(:items) > many_to_one :category > end > > class Category <

Re: Add "where" when "or" method is used on Dataset with no initial "where" set

2019-02-08 Thread Jeremy Evans
On Friday, February 8, 2019 at 1:55:10 PM UTC-8, marc halperin wrote: > > Currently if we do DB[:items].or(b: 10) the sql generated would be SELECT > * FROM items which as the documentation says makes since because "the > default is WHERE true, and OR would be redundant,". > > The issue with

Re: A way to enforce calling #all on a dataset we eager loading specified

2019-02-08 Thread Jeremy Evans
On Friday, February 8, 2019 at 7:13:11 AM UTC-8, Janko Marohnić wrote: > > Hello Jeremy, > > When specifying that a dataset should eager load certain associations, we > don't always remember to call #all when retrieving records. We often > accidentally call #each or #map or `#to_a`, in which

Re: An easier way to eager load associations when retrieving a single record by id

2019-02-08 Thread Jeremy Evans
On Friday, February 8, 2019 at 3:32:09 AM UTC-8, Janko Marohnić wrote: > > I'm looking for an easy way to apply eager loading of any nested > association for a single record, ideally performed at the same time when > the record is retrieved. Currently I can achieve this with: > > artist =

Re: Shards and Datasets

2019-02-06 Thread Jeremy Evans
On Wednesday, February 6, 2019 at 7:41:20 AM UTC-8, Jason Landry wrote: > > Suppose we have a production database with a smaller sandboxed version of > that database (that may existing on another server).This is easy enough > to use with shards (after setting up the database option :servers

Re: multi_insert returning: :primary_key

2019-02-04 Thread Jeremy Evans
On Monday, February 4, 2019 at 12:04:17 PM UTC-8, Jason Landry wrote: > > If I do a something like this (using postgres): > > rows = [ > {name: 'Bob'}, > {name: 'Cathy'}, > {name: 'Steve'} > ] > > results = Users.multi_insert(rows, return: :primary_key) > > => [1,2,3] > > Can I reliably

Sequel 5.17.0 Released

2019-02-01 Thread Jeremy Evans
Sequel 5.17.0 has been released! = New Features * An instance-level skip_auto_validations method has been added to the auto_validations plugin, allowing you to skip all or specific types of auto validations inside the block: model_instance.skip_auto_validations(:unique) do puts

Re: How to use Where IN "string_to_array" with Sequel?

2019-02-01 Thread Jeremy Evans
On Friday, February 1, 2019 at 6:54:59 AM UTC-8, genc wrote: > > Hi Jeremy, > > On PostgreSQL there is a string_to_array function. This is currently What > I am doing: > > UPDATE files SET date="2007-10-10 10:50:22" WHERE id in(1,2,3,4,5..) > > > However, IDs can be very large and can be

Re: Multi insert with PG opens an unnecessary transaction

2019-01-30 Thread Jeremy Evans
On Wednesday, January 30, 2019 at 12:50:43 PM UTC-8, Nikita Shilnikov wrote: > > Hello, > > It seems to me starting a new transaction in PG isn't necessary since it > will be executed as a single SQL statement >

Re: Loading Sequel Database Extension fails

2019-01-30 Thread Jeremy Evans
On Wednesday, January 30, 2019 at 4:37:44 AM UTC-8, athomas.esa...@gmail.com wrote: > > I'm exploring using the database extension pg_triggers. > > Following the doc at > https://github.com/jeremyevans/sequel/blob/master/doc/extensions.rdoc, I > get the following error: > > warning: LoadError:

Re: Ordering the results from an UPDATE .. RETURNING statement?

2019-01-25 Thread Jeremy Evans
On Friday, January 25, 2019 at 12:33:12 PM UTC-8, Greg H wrote: > > Hi Jeremy > > As per your suggestion, the CTE form works - many thanks. > > I quickly tried the sub-query form, but seems busted. Details below if > you're interested. > I guess PostgreSQL's SQL parser doesn't support the

Re: Ordering the results from an UPDATE .. RETURNING statement?

2019-01-25 Thread Jeremy Evans
On Friday, January 25, 2019 at 9:42:37 AM UTC-8, Greg H wrote: > > Hi there > > I'd like to order the results from an UPDATE .. RETURNING statement > (sequel's .returning() method). > Is this possible? > My approach detailed below isn't working, so I'd appreciate some advice. > > Many thanks >

Re: Some operators don't work as expected with coercion

2019-01-24 Thread Jeremy Evans
On Thursday, January 24, 2019 at 4:49:56 PM UTC-8, Janko Marohnić wrote: > > Hello again, > > Recently I was writing a query with the ANY Postgres operator, and was > trying out the following: > > DB[:table].where{"string" =~ ANY(DB[:some_dataset].select(:value))} > > The query wasn't working,

Re: Views with models?

2019-01-22 Thread Jeremy Evans
On Tuesday, January 22, 2019 at 1:09:46 PM UTC-8, Michael Faughn wrote: > > TL;DR -- I would like to be able to create models that were associated > with views. Is there a way to do this? > > Let's say I have the following kinds of Sequel::Model (and attendant > tables) with the attributes and

Re: Sequel `server_logging` extension and `preconnect` option

2019-01-21 Thread Jeremy Evans
On Wednesday, January 9, 2019 at 10:45:06 PM UTC-8, Jeremy Evans wrote: > > On Wednesday, January 9, 2019 at 5:12:09 PM UTC-8, Василий Колесников > wrote: >> >> Hi all! Thanks for the great software! >> >> I came across a strange behavior: when I use `pre

Re: #association_join doesn't include the default order specified at the association-level

2019-01-21 Thread Jeremy Evans
On Monday, January 21, 2019 at 5:27:06 AM UTC-8, Janko Marohnić wrote: > > Hi Jeremy, thank you for the explanation, that makes sense. > > If the only thing that would happen is that the ORDER BY of the joined > dataset wouldn't be applied, then I might argue that Sequel could still add > it

Re: Configure bin/sequel to use Pry as default?

2019-01-18 Thread Jeremy Evans
On Friday, January 18, 2019 at 9:47:51 AM UTC-8, Jeremy Evans wrote: > > On Friday, January 18, 2019 at 9:33:52 AM UTC-8, Tim Tilberg wrote: >> >> Hi Jeremy, would you be open to a way to configure Pry as a default >> `sequel` shell? I don't know what the best way

Re: Configure bin/sequel to use Pry as default?

2019-01-18 Thread Jeremy Evans
On Friday, January 18, 2019 at 9:33:52 AM UTC-8, Tim Tilberg wrote: > > Hi Jeremy, would you be open to a way to configure Pry as a default > `sequel` shell? I don't know what the best way to accomplish that would be, > but in my copies of the gem, I usually replace IRB with Pry in >

Re: Sequel `server_logging` extension and `preconnect` option

2019-01-09 Thread Jeremy Evans
On Wednesday, January 9, 2019 at 5:12:09 PM UTC-8, Василий Колесников wrote: > > Hi all! Thanks for the great software! > > I came across a strange behavior: when I use `preconnect: :concurently` > option for connection then `server_logging` extension doesn't work. > > Here is an example: > > #

Re: Dose sequel supports table valued parameters?

2019-01-07 Thread Jeremy Evans
On Monday, January 7, 2019 at 12:11:50 PM UTC-8, r...@goodsoundclub.com wrote: > > Thanks, Jeremy. I made this work as below, learning in the way some Ruby > syntax. My way went brutal but will work for now, I need to trace how the > actual inserts implemented and get some permanence metrics. I

Re: Dose sequel supports table valued parameters?

2019-01-06 Thread Jeremy Evans
On Sunday, January 6, 2019 at 2:04:30 PM UTC-8, r...@goodsoundclub.com wrote: > > Jeremy, thank you very much. The Dataset#import indeed looks very > promising. I just tried it and works fine but what I went to complicate the > things I faced a problem. In you documentation you say that the

Re: Dose sequel supports table valued parameters?

2019-01-06 Thread Jeremy Evans
On Sunday, January 6, 2019 at 4:33:23 AM UTC-8, r...@goodsoundclub.com wrote: > > Hi, I am new to ruby/sequel, work in different field: .Net, Go. I came > across a need to make fluentD to insert json to MSSQL to support some > legacy systems. Decided to write a plugin for fluent, hello Ruby… >

Re: #association_join doesn't include the default order specified at the association-level

2019-01-04 Thread Jeremy Evans
On Friday, January 4, 2019 at 10:22:31 AM UTC-8, Jeremy Evans wrote: > > On Friday, January 4, 2019 at 8:57:19 AM UTC-8, Janko Marohnić wrote: >> >> The following example: >> >> require "sequel" >> >> DB = Sequel.mock >> >> class Art

Re: #association_join doesn't include the default order specified at the association-level

2019-01-04 Thread Jeremy Evans
On Friday, January 4, 2019 at 8:57:19 AM UTC-8, Janko Marohnić wrote: > > The following example: > > require "sequel" > > DB = Sequel.mock > > class Artist < Sequel::Model > one_to_many :albums, order: :created_at > end > > class Album < Sequel::Model > end > > puts

Re: Unit Tests

2019-01-04 Thread Jeremy Evans
On Friday, January 4, 2019 at 7:39:46 AM UTC-8, athomas.esa...@gmail.com wrote: > > Excellent, thank you. I wasn't sure what workflow / setup steps were > needed. > In general, "gem install --development sequel" should be all you need. You shouldn't need to install bundler or use bundle exec,

Sequel 5.16.0 Released

2019-01-02 Thread Jeremy Evans
Sequel 5.16.0 has been released! = New Features * Database#rollback_on_exit has been added, which allows you to rollback transactions instead of committing them when exiting the transaction block. Previously, the only way to rollback a transaction from inside a transaction block was to

Re: Consider adding `dataset.any?` as inverse of `dataset.empty?`

2018-12-30 Thread Jeremy Evans
On Saturday, December 29, 2018 at 10:59:10 PM UTC-8, fran.em.wor...@googlemail.com wrote: > > While I get that `if !dataset.empty?` vs `unless dataset.any?` is a matter > of taste it seems confusing that `.any?` is a valid method but is not > equivalent to `!empty?` in terms of query

Re: Creating master method for models

2018-12-25 Thread Jeremy Evans
On Tuesday, December 25, 2018 at 8:50:32 AM UTC-8, genc wrote: > > Hi Jeremy, > > I have models like this: > > > class Mailbox::Email < Mailbox::Model(:emails) > end > class Mailbox::Post < Mailbox::Model(:emails) > end > > > and of course a base class: > > module Mailbox > def

Re: How to make sure jsonb fields are symbolic hashes when fetched?

2018-12-25 Thread Jeremy Evans
On Tuesday, December 25, 2018 at 7:37:58 AM UTC-8, genc wrote: > > Hi Jeremy, > > When I do this: > > class User < Sequel::Model > ... > end > > user = User.new > user.properties = { name: 'Genc', age: 42 } # or ':name =>..., ' > user.save > > #try to fetch assigned data > user.properties[:name]

Re: Problem with own dataset extension module

2018-12-21 Thread Jeremy Evans
On Friday, December 21, 2018 at 9:16:14 AM UTC-8, Danilo Nogueira wrote: > > Hi! > > I'm developing an Sequel::Dataset extension, and everything seems to be > working fine. This is my extension > . > I Installed it on a Rails project, and tried

Re: How to use timeout limit in threads

2018-12-19 Thread Jeremy Evans
On Wednesday, December 19, 2018 at 3:34:09 AM UTC-8, akud...@amarkets.com wrote: > > #!/usr/bin/env ruby > > require 'mysql2' > require 'sequel' > > CONF = { > adapter: 'mysql2', > encoding: 'utf8', > username: 'ruby', > password: 'ruby', > host: 'localhost', > port: 3306, > pool:

Re: updating a one_to_one association via nested_attributes calls validate twice and clears reciprocal association the second time

2018-12-13 Thread Jeremy Evans
On Thursday, December 13, 2018 at 1:34:00 PM UTC-8, Ben Alavi wrote: > > Actually... do you know why the reciprocal object isn't just replaced > *before* calling the setter? > > This works for my example and passes specs: > > remove_reciprocal_object(opts, a) if a >

Re: updating a one_to_one association via nested_attributes calls validate twice and clears reciprocal association the second time

2018-12-13 Thread Jeremy Evans
On Thursday, December 13, 2018 at 12:43:42 PM UTC-8, Ben Alavi wrote: > > Oh yep just got there! > > So I think I see what you mean -- if a and o already had the same > reciprocal association set you could avoid the same issue by checking for > that as well...something like: > >

Re: updating a one_to_one association via nested_attributes calls validate twice and clears reciprocal association the second time

2018-12-13 Thread Jeremy Evans
On Thursday, December 13, 2018 at 12:14:22 PM UTC-8, Ben Alavi wrote: > > That makes sense to me, although it looks like what should happen before > your change is that > > >

Re: updating a one_to_one association via nested_attributes calls validate twice and clears reciprocal association the second time

2018-12-13 Thread Jeremy Evans
On Thursday, December 13, 2018 at 10:01:57 AM UTC-8, Ben Alavi wrote: > > This does fix the issue for us because we are so far only referencing the > reciprocal association in the validate method, however I think there is > still an issue with the reciprocal association being cleared that is not

Re: updating a one_to_one association via nested_attributes calls validate twice and clears reciprocal association the second time

2018-12-13 Thread Jeremy Evans
On Thursday, December 13, 2018 at 7:34:01 AM UTC-8, Jeremy Evans wrote: > > On Wednesday, December 12, 2018 at 11:55:14 PM UTC-8, Ben Alavi wrote: >> >> Hey Jeremy, >> >> I believe this is a bug: >> >> Example: >> https://gist.github.com/benalavi/2

Re: updating a one_to_one association via nested_attributes calls validate twice and clears reciprocal association the second time

2018-12-13 Thread Jeremy Evans
On Wednesday, December 12, 2018 at 11:55:14 PM UTC-8, Ben Alavi wrote: > > Hey Jeremy, > > I believe this is a bug: > > Example: https://gist.github.com/benalavi/20817b785a08d16912f82ce31afde029 > > The create works, the update fails. > > Both the create and update call validate twice on the

Re: Use superclass qualifier when inferring subclass source tables when using CTI w/ qualified dataset

2018-12-11 Thread Jeremy Evans
On Monday, December 10, 2018 at 11:24:46 PM UTC-8, Ben Alavi wrote: > > Think I found a bug with this: it doesn't qualify subclasses of subclasses > as table_name will return the alias when subclassing a subclass. Checking > cti_table_name rather than table_name works, but I believe it is

Re: SQL formatter/pretty-printer

2018-12-10 Thread Jeremy Evans
On Monday, December 10, 2018 at 9:53:08 AM UTC-8, vais wrote: > > Is there any way to format/pretty-print the SQL generated/logged by Sequel > so that it’s easier to read? > > Especially in the process of learning/adopting Sequel and using it to > write a complex query, it would help a lot to

Re: Allowing CTI models to take advantage of the schema cache

2018-12-07 Thread Jeremy Evans
On Friday, December 7, 2018 at 12:20:03 AM UTC-8, Kenaniah Cerny wrote: > > Hi all, > > I have a code base that is currently using both the schema_caching > extension and the class_table_inheritance model plugins. I noticed that the > CTI plugin does not utilize the schema cache even when it is

Re: HOW: Another self-join we'd like to rewrite in Sequel

2018-12-04 Thread Jeremy Evans
On Tuesday, December 4, 2018 at 9:44:58 AM UTC-8, Eric Promislow wrote: > > > … >> You could probably try: >> >> ProcessModel.db.from(Sequel[:processes].as(:p1), >> Sequel[:processes].as(:p2)) >> >> Thanks, >> Jeremy >> > > The generated SQL doesn't make sense, for both Postgres and MySQL: > >

Re: HOW: Another self-join we'd like to rewrite in Sequel

2018-12-03 Thread Jeremy Evans
On Monday, December 3, 2018 at 6:39:00 PM UTC-8, Eric Promislow wrote: > > This isn't working with Sequel 4.49.0 (We have documented problems > migration to v5 due to mis-resolution of symlinks.) > As a general rule, the code examples I post apply to the current version of Sequel. They may

Re: Many-to-many problem with TinyTDS

2018-12-03 Thread Jeremy Evans
On Monday, December 3, 2018 at 3:35:32 PM UTC-8, Jeff Dyck wrote: > > I'm trying to setup a many-to-many relationship on a legacy database > (which hopefully explains the ugly and non-Sequel standard table and field > names), which I *think* I've done ok, unfortunately it's triggering a >

Re: HOW: Another self-join we'd like to rewrite in Sequel

2018-12-03 Thread Jeremy Evans
On Monday, December 3, 2018 at 1:54:54 PM UTC-8, Eric Promislow wrote: > > Hi, > > We want to find all but the most recent processes for each app based on > the :created_at field. Here's the raw SQL that works: > > mysql> select distinct p1.id >from processes p1 join processes p2 >

Re: Mapping query results to an object

2018-12-03 Thread Jeremy Evans
On Monday, December 3, 2018 at 8:08:21 AM UTC-8, Jeremy Hinegardner wrote: > > Hey all, > > I'm working with a legacy database and looks like our best strategy for > managing things is going to be using Datasets and Database directly (lots > of non-trivial queries for the domain/business

Re: Convert empty string to nil during mass assignment

2018-12-02 Thread Jeremy Evans
On Sunday, December 2, 2018 at 7:55:00 PM UTC-8, craig buchanan wrote: > > Is there a way to automatically convert empty string to nils during mass > assignment? > > Currently: > > irb(main):016:0> c = {first_name:'micky',last_name:'mouse',title:''}=> {: > first_name=>"micky",

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 actually throws an error,

Re: selecting first element from array_agg function

2018-12-01 Thread Jeremy Evans
On Thursday, November 15, 2018 at 11:45:14 PM UTC-8, Jeremy Evans wrote: > > On Thursday, November 15, 2018 at 3:43:07 PM UTC-8, Artur Trofimov wrote: >> >> I fixed it with >> Sequel.lit('(array_agg(grades.section_id))[1]') >> >> but maybe it can be done in

Sequel 5.15.0 Released

2018-12-01 Thread Jeremy Evans
Sequel 5.15.0 has been released! = New Features * A :qualify_tables option has been added to the class_table_inheritance plugin, which will automatically qualify subclass tables with the same qualifier as the superclass table if the superclass table is qualified. *

Re: add_spatial_index

2018-11-30 Thread Jeremy Evans
On Friday, November 30, 2018 at 4:52:52 AM UTC-8, Bruce Steedman wrote: > > I noticed this method briefly described in the docs > . > > I just tried to use it to index columns

Re: How do we find the lowest unused positive integer in a table?

2018-11-27 Thread Jeremy Evans
On Tuesday, November 27, 2018 at 5:14:51 PM UTC-8, Eric Promislow wrote: > > I've done enough digging to know this involves self-joins, but I'm not > sure how to combine everything. > > I've got a table `mangos` with a column `pseudo_id` which I'd like to be > as small a positive integer as

Re: ID ambiguous exception in remove_* method association involving class table inheritance

2018-11-27 Thread Jeremy Evans
On Tuesday, November 27, 2018 at 6:55:35 AM UTC-8, Sachu Thomas Isaac wrote: > > Hi, > > Following are the 3 classes in which one class is of class table > inheritance > > class User < Sequel::Model > #table_name :users > plugin :class_table_inheritance, key: :type > end > > class Employee <

Re: Does Dataset#import return primary keys in defined order?

2018-11-21 Thread Jeremy Evans
On Wednesday, November 21, 2018 at 7:41:19 PM UTC-8, Jason wrote: > > I am figuring out how to import bulk CSV data where each input row will > result in a created record in one table with one or more associated records > in another table. I'd like to continue using Dataset#import but the >

Re: About Athena support

2018-11-20 Thread Jeremy Evans
On Tuesday, November 20, 2018 at 6:26:57 PM UTC-8, Yves Cui wrote: > > Hello, > > We are use sequel for traditional RMDBS, and using Athena to query data on > S3 too. > I'm wondering if Sequel can/will support Athena ? > There are no plans to ship support for Athena in Sequel. However, people

Re: Use superclass qualifier when inferring subclass source tables when using CTI w/ qualified dataset

2018-11-20 Thread Jeremy Evans
On Tuesday, November 20, 2018 at 4:30:23 PM UTC-8, Ben Alavi wrote: > > Patch that would take a new :qualify_tables option to the CTI plugin: > > https://gist.github.com/benalavi/159110fd58907c7925fc8bd1958e3ad2 > > So the API would be: > > plugin :class_table_inheritance, qualify_tables: true >

Newish Sequel User Seems To Have Broken Sequel

2018-11-16 Thread Jeremy Evans
Don't override initialize, that's probably what broke things. Also, load plugins into Sequel::Model before subclassing it, not after. See the Code Order guide on the Sequel website. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk"

Re: selecting first element from array_agg function

2018-11-15 Thread Jeremy Evans
On Thursday, November 15, 2018 at 3:43:07 PM UTC-8, Artur Trofimov wrote: > > I fixed it with > Sequel.lit('(array_agg(grades.section_id))[1]') > > but maybe it can be done in a more beautiful way > One way to handle this is to have Sequel::SQL::Function#sql_subscript wrap the receiver in

Re: Favorites model

2018-11-15 Thread Jeremy Evans
On Thursday, November 15, 2018 at 1:45:45 PM UTC-8, craig buchanan wrote: > > I'm not sure that I follow. > > This doesn't work, obviously: > > User[1].add_contact(Contact[1], type: 'contact') > > Not by default, but you can use the :adder option to support it (IIRC, using something like

Re: adding more conditions on inner join when using recursive

2018-11-15 Thread Jeremy Evans
On Thursday, November 15, 2018 at 12:43:03 AM UTC-8, genc wrote: > > Hi Jeremy, > > I want to add more conditions to inner join after ON but it appends and > treat as array instead of merging conditions. > > Let me show you the full query builder: > > DB[:full_paths]. > select(:id, :subject).

Re: sequel_append scalar query

2018-11-14 Thread Jeremy Evans
On Wednesday, November 14, 2018 at 1:04:11 PM UTC-8, craig buchanan wrote: > > I have three tables: > > users --< users_entities >-- entities > > User model: > > many_to_many :entities, > :class => Contact, :join_table => :users_entities, > :left_key => :user_id, :right_key =>

<    2   3   4   5   6   7   8   9   10   11   >