Re: ORM models and postgresql schemas (namespaces)

2024-02-20 Thread Jeremy Evans
On Tue, Feb 20, 2024 at 2:11 PM Konstantin Dzreev wrote: > Hi guys. > > I have a postgresql database with multiple schemas (namespaces). > Is there a way to use namespaces with ORM models? I did not find an easy > way to tell all my models what namespace they should switch to. > > ```ruby >

Re: Connection after disconnect

2023-12-27 Thread Jeremy Evans
> ב-יום שני, 20 בנובמבר 2023 בשעה 18:08:26 UTC+2, Jeremy Evans כתב/ה: > >> On Mon, Nov 20, 2023 at 3:21 AM Sofia Dimant wrote: >> >>> thank you >>> are the parameters set in Sequel.connect are global for all the >>> connection? >>> I'm asking b

Re: Forcefully disconnect Sequel

2023-12-18 Thread Jeremy Evans
On Mon, Dec 18, 2023 at 7:08 AM Arne Jarek wrote: > Hey there, > > is there any way to forcefully disconnect running/active connections on > the postgres adapter? thanks. > > Sorry for triple posting, I just can't seem to see my own posts. > Sequel does not offer that capability. One reason is

Re: Expressing DIV operator

2023-12-18 Thread Jeremy Evans
On Mon, Dec 18, 2023 at 5:43 AM Stéphane D'Alu wrote: > Hi > > I'm trying to write something like: > > SELECT UNIX_TIMESTAMP(`time`) DIV 3600 * 3600 > > So far I managed to write: > > SELECT UNIX_TIMESTAMP(`time`) / 3600 * 3600 > > using > > DB.select(Sequel.function(:UNIX_TIMESTAMP, :time) /

Re: Model usage in bin/sequel

2023-11-21 Thread Jeremy Evans
On Tue, Nov 21, 2023 at 8:24 AM John Knapp wrote: > I cannot find documentation for using models within bin/sequel. > > In bin/sequel Users.first gives uninitialized constant error while > DB[:users].first works as expected. Models in my routes work fine (also, > as expected.) > > I suspect I'm

Re: Connection after disconnect

2023-11-20 Thread Jeremy Evans
On Mon, Nov 20, 2023 at 3:21 AM Sofia Dimant wrote: > thank you > are the parameters set in Sequel.connect are global for all the connection? > I'm asking because I Im using RDS with IAM, and Im not sure where should I > add the password update. my application performs Sequel.connect couple of >

Re: Connection after disconnect

2023-11-19 Thread Jeremy Evans
On Sun, Nov 19, 2023 at 12:34 AM Sofia Dimant wrote: > I have a rails application (with puma) and postgresql databases. As a DB > driver gem Sequel is used. > > I did a test in my program and saw that in this code: > def test_select > db = Sequel::Model.db = Sequel.connect(@database_url) >

Re: Defining association with order by on another table

2023-11-19 Thread Jeremy Evans
On Sat, Nov 18, 2023 at 10:52 PM aryk@gmail.com wrote: > lets say you have: > > class User > one_to_one :best_purchase, class: :Purchase > end > class Purchase > many_to_one :product > end > class Product > # has column :tier which is a number. > end > > I want to do something like > >

Re: Connection Pool and Memory Leak

2023-11-16 Thread Jeremy Evans
On Thu, Nov 16, 2023 at 2:25 PM Josh (joshofclubs52) wrote: > One thing that may help is that I notice the app is leaving a lot of > transactions in the "idle" / COMMIT state. I know that usually isn't a good > indicator, but the number of those continues to climb. > If the application is

Re: Using Seguel.delay in models with pg_json extension

2023-11-04 Thread Jeremy Evans
On Sat, Nov 4, 2023 at 12:55 PM Juan Manuel Cuello wrote: > Hi, > > I'm having problems when using the pg_json extension with models that > load the table name using Seguel.delay. > > DB.extension :pg_json > > This works as expected: > > class Foo < Sequel::Model(DB.from(:foo)) > end > >

Re: validation_helpers

2023-10-29 Thread Jeremy Evans
On Sun, Oct 29, 2023 at 3:40 AM bee...@gmail.com wrote: > For some reason I can't get the validation_helpers to load: > > > In the models loader: > *Sequel::Model.plugin :validation_helpers* > > Models are loaded after helpers. Inside the class that's been working: > *plugin

Re: SQLite

2023-10-23 Thread Jeremy Evans
On Mon, Oct 23, 2023 at 7:00 PM Roman Turner wrote: > Hi all, > > Is there support for running a migration over many SQLite databases? A > burgeoning thought is using a SQLite database per user as an easy way for > multi-tenancy and using a service like LiteStream to back them up in a > storage

Re: Password Field Auto-Encryption?

2023-09-27 Thread Jeremy Evans
On Wed, Sep 27, 2023 at 10:58 AM bee...@gmail.com wrote: > I reassigned that *Gen.pw* to *Gen.smallpw* and everything works fine. > So somehow that module method is getting confused. > > Is there anything you need me to try, provide? > It sounds like the problem is in Gen and not in Sequel, so

Re: Password Field Auto-Encryption?

2023-09-26 Thread Jeremy Evans
On Tue, Sep 26, 2023 at 6:53 AM bee...@gmail.com wrote: > A *non-Sequel* class definition has the proper static assignment of *a.pw > *, so this is a difference of *Sequel* vs *non-Sequel* class > definition, as I see it. If you put together a self contained reproducible example

Re: Password Field Auto-Encryption?

2023-09-24 Thread Jeremy Evans
On Sun, Sep 24, 2023 at 5:45 PM bee...@gmail.com wrote: > For soem reason I have a field that's changing upon assigning it as a > property value. I have no clue why. > > > > > > > > *DL.create_table? :pwtest do primary_key :id String :uname, size: 16 > String :pw, size: 64 DateTime

Re: Sequel and Postgres versions supported

2023-09-11 Thread Jeremy Evans
On Mon, Sep 11, 2023 at 7:17 PM Raghu Sontam wrote: > Hello: > > We are currently looking to upgrade from Postgres 13.x to Postgres 15.x. > > Is there a compatibility/support matrix published anywhere that lists > versions of Postgres supported by Sequel? > > What are the ways to confirm

Re: More hstore

2023-08-21 Thread Jeremy Evans
On Mon, Aug 21, 2023 at 11:02 AM bee...@gmail.com wrote: > OK, so I'm now even more confused. I am assuming that there is a direct > way of asking for records whose hstore field has a single value. Is this a > correct assumption? A better question to ask yourself is: "What PostgreSQL

Re: More hstore

2023-08-17 Thread Jeremy Evans
On Thu, Aug 17, 2023 at 3:11 AM bee...@gmail.com wrote: > I'm wanting to find records whose stored hash has a value (eventually > values). Searching for keys works, but values doesn't: > > *res = > htable.where(Sequel.hstore(:hstore_col).has_key?(keychoice)).select_map(:id)* > > While there is

Re: Accessor for joined columns

2023-08-15 Thread Jeremy Evans
On Tue, Aug 15, 2023 at 2:40 AM beths...@gmail.com wrote: > Hi Sequels, > > I'm sure I saw a plugin/method/configuration that allows joined columns > that don't belong to the model to be accessed via methods ( > query.all.first.foo), instead of via the hash (query.all.first[:foo]), > but now I

Re: Batch updates not using "on duplicate key update" on postgres

2023-08-09 Thread Jeremy Evans
On Wed, Aug 9, 2023 at 11:35 AM aryk@gmail.com wrote: > Hi Jeremy, > > I saw some historical posts about batch updates like this one: > > https://groups.google.com/g/sequel-talk/c/uV7PRbEvQj0/m/lCvZaLx8AAAJ > > It feels a little "hacky" to say insert this record with a unique primary > key

Re: hstore Errors

2023-08-06 Thread Jeremy Evans
On Sun, Aug 6, 2023 at 8:11 AM bee...@gmail.com wrote: > Ah I also didn't know you needed the gem *pg_hstore*. No, you don't. hstore support ships with Sequel. pg_hstore is unrelated to Sequel and does not provide a sequel/extensions/hstore.rb file:

Re: hstore Errors

2023-08-05 Thread Jeremy Evans
On Sat, Aug 5, 2023 at 3:52 PM bee...@gmail.com wrote: > For some reason I can't seem to Hash.store. > > > > > > > > *a = {:a => "orange",:b => "red",:c => "green"}trial = > Sequel.hstore(a)ap trial* > > Throws error: > > > > > > > > > > > *{:a => "orange",:b => "red",

Re: Clarification on how fiber_concurrency extension should work

2023-07-21 Thread Jeremy Evans
On Fri, Jul 21, 2023 at 9:45 AM 'Michael Scrivo' via sequel-talk < sequel-talk@googlegroups.com> wrote: > I can already see that in my attempt at reproducing with sqllite, all > queries are using the same connection, despite sett max_connections to 5. > Are you using a memory database? If so,

Re: Clarification on how fiber_concurrency extension should work

2023-07-21 Thread Jeremy Evans
On Fri, Jul 21, 2023 at 8:58 AM 'Michael Scrivo' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hey Jeremy, > > We currently use Sequel with Sharded Connection Pooling (5-10 threads > usually) in our codebase, connecting to postgres instances, along with some > select usages of Async

Re: Setting up connection for PG, readonly

2023-07-19 Thread Jeremy Evans
On Tue, Jul 18, 2023 at 2:14 PM matob...@gmail.com wrote: > Ok, so jumping back to this. So I can control my dev database, but not > the real one used in auto testing. > > If I wanted to try to go the route of setting `SET SESSION CHARACTERISTICS > AS TRANSACTION READ ONLY;` > Is there a way to

Re: Setting up connection for PG, readonly

2023-07-10 Thread Jeremy Evans
On Mon, Jul 10, 2023 at 3:40 PM matob...@gmail.com wrote: > So I have a application that makes two different PG connection pools, one > to a read-only server, and one to a read-write server. > All was going great, until I accidentally use my RO connection for a write. > > Sadly, all my automated

Re: Set dataset.db= on Sequel 5

2023-06-16 Thread Jeremy Evans
On Fri, Jun 16, 2023 at 10:48 AM Rui Santos wrote: > Hi, we are upgrading from sequel 4 to sequel 5 and we now since datasets > are frozen I wonder how we could set the dataset database at runtime. > > We have a lot of code that will build a dataset with chaining and then > change the database

Re: Sequel::NotNullConstraintViolation

2023-06-10 Thread Jeremy Evans
On Fri, Jun 9, 2023 at 11:58 PM Vladimir Shkurin wrote: > Hello! I created a simple user registration form with Sequel and Roda, but > an error occurs when filling out the fields and submitting the form. > > Sequel::NotNullConstraintViolation at /user/new > SQLite3::ConstraintException: NOT NULL

Re: Could there be a better way to set created_at on a join table?

2023-05-31 Thread Jeremy Evans
On Wed, May 31, 2023 at 8:44 AM Esteban wrote: > Howdy! Huge fan of the forum, and all the work you do Jeremy. > > I'm using the timestamps plugin, and I discovered that created_at isn't > set for join tables. This is expected, as the plugin only handles timestamps for the current model, not

Re: Lazy db connection

2023-04-08 Thread Jeremy Evans
On Sun, Apr 9, 2023 at 10:34 AM jonatha...@gmail.com < jonathan.fri...@gmail.com> wrote: > If you look at the docs at > https://github.com/jeremyevans/sequel/blob/master/doc/opening_databases.rdoc, > there is a `test` option you can pass to the connect method. I believe that > is what you're

Re: Lazy db connection

2023-04-08 Thread Jeremy Evans
On Sat, Apr 8, 2023 at 2:01 AM jaso...@gmail.com wrote: > I'll preface this question: We still have to work through upgrading > deprecation warnings so we can upgrade to Sequel 5.0/Ruby 3 (we're on > 4.49.0/2.7.3) > > The system I work on has numerous postgres databases it connects to (it's > a

Re: Directed Acyclic Graph

2023-02-15 Thread Jeremy Evans
On Wed, Feb 15, 2023 at 6:04 AM abhijit wrote: > I need to create the following (data representation) - > Part P > - Part X > - Part Z > > Part Q > - Part X > - Part Z > > I was thinking this could be done by using a directed acyclic graph (dag)? > > So, I was thinking of having two

Re: Circuit breakers

2023-02-14 Thread Jeremy Evans
On Tue, Feb 14, 2023 at 10:12 AM Tomás Miguez wrote: > Hello everyone! > > We are currently experiencing some database problems and would like to > hear your opinions. Our database is sharded, and occasionally, one of the > shards becomes inaccessible. When a service attempts to access it, a >

Re: PG::ConnectionBad: PQconsumeInput() SSL error: decryption failed or bad record mac

2023-02-09 Thread Jeremy Evans
gt; >> >> DB = Sequel.connect(ENV['SCALINGO_POSTGRESQL_URL']) >> DB.extension(:connection_validator) # is implementing the extension as >> easy as adding this?? >> >> Le jeudi 9 février 2023 à 17:15:13 UTC+1, Thiebo a écrit : >> >>> thanks Jeremy! >>> >>&

Re: PG::ConnectionBad: PQconsumeInput() SSL error: decryption failed or bad record mac

2023-02-09 Thread Jeremy Evans
On Thu, Feb 9, 2023 at 1:21 AM Thiebo wrote: > Hi ! > > I have an application that is working fine locally, but on the server (env > production) raises this error : > > 2023-02-08 16:39:20.329238105 +0100 CET [web-1] 2023-02-08 15:39:20 - > Sequel::DatabaseDisconnectError - PG::ConnectionBad:

Re: SQL Server index table hints using Sequel DS api?

2023-01-25 Thread Jeremy Evans
On Wed, Jan 25, 2023 at 3:16 PM Tim Tilberg wrote: > I've spent a lot of time today trying to find this out on my own but have > not made progress. > > I'm using SQL Server and tinytds. My query optimizer is choosing a poor > index for reasons yet unknown and I need to specify a table hint until

Re: warning: undefining the allocator of T_DATA class TinyTds::Result

2023-01-23 Thread Jeremy Evans
On Mon, Jan 23, 2023 at 11:37 AM Paul wrote: > What to make of this warning, which started to appear ever since upgrading > to ruby 3.2.0 ?: > > /opt/rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/sequel-5.64.0/lib/sequel/adapters/tinytds.rb:34: > warning: undefining the allocator of T_DATA class

Re: Multiple databases issues

2023-01-16 Thread Jeremy Evans
On Mon, Jan 16, 2023 at 4:32 AM Artem S wrote: > I have a rails application (with puma) and few postgresql databases. As a > DB driver gem Sequel is used. Here is the code for multiple DB connections > when application starting: > > require "sequel" > > module MyApp > class Databases >

Re: foreign key constraint

2023-01-09 Thread Jeremy Evans
On Mon, Jan 9, 2023 at 9:57 AM Thiebo wrote: > Hello ! > > I have this migration : > > create_table(:deleted_categories) do > primary_key :id, :type=>:Bignum > String :intitule, size: 250, null: false > String :sens, size: 10, null: false, default: 'depense' > DateTime :created_at, :null=>false,

Re: Partitioned table breaks our ability to automatically detect the existing indexes

2023-01-03 Thread Jeremy Evans
remy > Thanks ahead. > Maria. > > On Thursday, December 1, 2022 at 12:54:14 AM UTC-5 Jeremy Evans wrote: > >> On Thu, Dec 1, 2022 at 2:28 AM 'Maria Fradkin' via sequel-talk < >> seque...@googlegroups.com> wrote: >> >>> Yes, working perfectly! Thank you ve

Re: Partitioned table breaks our ability to automatically detect the existing indexes

2022-11-30 Thread Jeremy Evans
the January 2023 release. Thanks, Jeremy On Wednesday, November 30, 2022 at 10:52:31 AM UTC-5 Jeremy Evans wrote: > >> On Wed, Nov 30, 2022 at 11:19 PM 'Maria Fradkin' via sequel-talk < >> seque...@googlegroups.com> wrote: >> >>> Hello, >>

Re: Partitioned table breaks our ability to automatically detect the existing indexes

2022-11-30 Thread Jeremy Evans
On Wed, Nov 30, 2022 at 11:19 PM 'Maria Fradkin' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hello, > > I have discovered one additional problem related to the partitioned tables > in Postgres. We use unique index and constraint definitions to handle > insert on conflict behaviour in

Re: Equivalent Fields

2022-11-15 Thread Jeremy Evans
On Tue, Nov 15, 2022 at 9:36 AM bee...@gmail.com wrote: > I need to find records where two fields are the same (strings). I've > tried a handful of things, but they call come back as 'WHERE false'. > Here's the two that I thought would work: > > puts d.where(Sequel(:field1 ==

Re: Why is find not recommended?

2022-11-08 Thread Jeremy Evans
On Tue, Nov 8, 2022 at 7:02 AM Tomás Miguez wrote: > Hello, > I was reading the documentation for the find method of model ( > https://www.rubydoc.info/github/jeremyevans/sequel/Sequel%2FModel%2FClassMethods:find) > and noticed that it recommends using other approaches: "You are encouraged > to

Re: SQLite FTS

2022-11-07 Thread Jeremy Evans
On Sun, Nov 6, 2022 at 11:39 PM Roman Turner wrote: > Howdy, > > I have recently stumbled upon Sequel and I have been playing around with > SQLite more. When I was attempting to create a simple full text search. > Following the example in the SQLite >

Re: Field Value Length

2022-11-05 Thread Jeremy Evans
On Sat, Nov 5, 2022 at 5:52 AM bee...@gmail.com wrote: > How can I delete records whose field values are greater than a certain > length? > > DL[:archives].where(:quotation.length > 300).delete > > I've also tried: > > DL[:archives].where(Sequel[:quotation.length] > 300).delete > You need to

Re: Similar issue

2022-11-02 Thread Jeremy Evans
On Wed, Nov 2, 2022 at 9:31 AM Priya wrote: > Hi Jeremy > I have a Postgres database and I'm using ruby. My Postgres connections has > permission for insert, select, update, and delete. I was able to delete > records without issue. However, on the update, it does get updated > momentarily but

Re: Union of multiple datasets

2022-10-21 Thread Jeremy Evans
On Fri, Oct 21, 2022 at 9:50 AM abhijit wrote: > Hi, > > I have multiple dataset queries. What would be the best way to create a > union in this scenario? > > I have tried - > > ds1.union(ds2.union(ds3.union))) > > as well as > > ds1.union(ds2).union(ds3) > > In either case, the resulting SQL

Re: model name different from table

2022-10-18 Thread Jeremy Evans
On Tue, Oct 18, 2022 at 12:50 PM Thiebo wrote: > Hi, > > I want to create a table `lignes_comptables` and a model `Ligne_comptable` > > How do I tell the model to look for a table lignes_comptables non > ligne_comptables ? > class Ligne_comptable < Sequel::Model(:lignes_comptable) end Be aware

Re: extract - there must be a better way

2022-10-08 Thread Jeremy Evans
On Sat, Oct 8, 2022 at 1:12 AM Thiebo wrote: > Hello, > > I currently do this: > > # create empty array to which result of dataset will be pushed > results = [] > > # get the Sequel dataset > DB[:entrees] > .join(:categories, id: :categorie_id) > .select{[ entrees[:id], entrees[:date_de_valeur],

Re: Queueing CTE

2022-10-07 Thread Jeremy Evans
On Fri, Oct 7, 2022 at 7:54 AM Bougy Man (bougyman) wrote: > I was trying to accomplish this on datasets and could not figure out the > magic. Using Model.with(:enqueued, Model.where(status: > 'ready').returning.update(status: 'processing')) does not work as expected > in this case. > > Here's

Re: Inconsistent Time result when querying using pg_sequel

2022-09-28 Thread Jeremy Evans
In my environment, with sequel_pg, your example gives: 2021-11-07 01:35:44 -0700 2022-02-21 08:22:37 -0800 2021-11-07 01:35:44 -0700 2021-03-23 08:36:22 -0700 2021-11-07 01:35:44 -0700 With NO_SEQUEL_PG, your example gives: 2021-11-07 01:35:44 -0800 2022-02-21 08:22:37 -0800 2021-11-07 01:35:44

Re: Inconsistent Time result when querying using pg_sequel

2022-09-27 Thread Jeremy Evans
On Tue, Sep 27, 2022 at 4:34 PM 'Charlie Pham' via sequel-talk < sequel-talk@googlegroups.com> wrote: > I was able to get sequel_pg running on my local and got the same output > you did. Interesting that I am not able to reproduce. > > Setting ENV["NO_SEQUEL_PG"] = "true" in the testing

Re: Inconsistent Time result when querying using pg_sequel

2022-09-27 Thread Jeremy Evans
On Tue, Sep 27, 2022 at 2:08 PM 'Charlie Pham' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hello, > > I have a model that has a field `created_at` that is of type timestamp > without timezone in Postgres. All of the relevant timezone settings are set > to `:local`. We are in PST (-8)

Re: FKs on partitioned tables

2022-09-27 Thread Jeremy Evans
On Tue, Sep 27, 2022 at 12:46 PM 'Maria Fradkin' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hello, > > I have recently came across a problem with foreign_key_list not working > correctly with partitioned tables on Postgres. > My table is partitioned by hash on some_id column, I have

Re: Multi insert with PG opens an unnecessary transaction

2022-09-19 Thread Jeremy Evans
On Mon, Sep 19, 2022 at 8:42 PM Daniel Rodgers-Pryor < djrodgerspr...@gmail.com> wrote: > I recently came accross these additional transactions when profiling our > app. Would you be open to a PR which removes the transactions when they're > not needed (when the group of inserts is a single

Re: Dataset w/ Joins + Eager Graph

2022-08-12 Thread Jeremy Evans
On Fri, Aug 12, 2022 at 11:15 AM Matt Culpepper wrote: > Hey Jeremy, > > I remember a while back, I asked about the use of graph and eager_graph > together, and you said it wasn't possible and (IIRC) to use join instead of > graph. > > I noticed something I thought was strange today. > >

Re: DSL for creating partitioned tables in Postgresql

2022-08-04 Thread Jeremy Evans
On Thu, Aug 4, 2022 at 9:20 AM Bougy Man wrote: > With PostgreSQL having native partitioning in 10+, is there a plugin > available that allows migrations to create a partitioned table by range? If > not, what are some best practices for including partitioined tables in a > sequel-backed

Re: Optimize massive data ingestion - Need Advice

2022-08-02 Thread Jeremy Evans
On Tue, Aug 2, 2022 at 5:25 AM Pierre Yager wrote: > Hello, > > Still working on this GeoNames database. > > After reading this guide in the PostgreSQL documentation ( > https://www.postgresql.org/docs/current/populate.html) i see some room of > improvement in my GeoNames dataset injestion

Re: Count many_to_many relation

2022-08-01 Thread Jeremy Evans
On Mon, Aug 1, 2022 at 9:05 AM fvbe...@gmail.com wrote: > Hi, > > How can I count a many_to_many relations when retrieving the list? > > Example: > > > # models > > class Artist < Sequel::Model(db[:artists]) > db[:artists] > Note that this db[:artists] call does nothing, you should

Re: Serialize Model to JSON with field aliases and functions

2022-07-29 Thread Jeremy Evans
On Fri, Jul 29, 2022 at 5:20 AM Pierre Yager wrote: > Hello, > > I'm somewhat new to sequel (but not in Ruby nor Rails/ActiveRecord). I'm > building an API based on geonames datasets. > > I want to export a subset of the country_info table : > > create table country_info > ( > iso_alpha2

Re: limit fires an extra query when offset is greater than 1

2022-07-11 Thread Jeremy Evans
> > On Mon, 11 Jul, 2022, 7:44 pm Jeremy Evans, > wrote: > >> On Mon, Jul 11, 2022 at 1:54 AM ashwin k wrote: >> >>> The extra query is getting triggered only when offset is greater than >>> zero. >>> >>> I didn't notice this query when

Re: limit fires an extra query when offset is greater than 1

2022-07-11 Thread Jeremy Evans
anks, Jeremy > On Sun, 10 Jul, 2022, 10:39 pm Jeremy Evans, > wrote: > >> On Sun, Jul 10, 2022 at 1:51 AM ashwin k wrote: >> >>> Not sure if first query can be ignored? >>> >> >> Not sure what you mean by "can be ignored". It's ne

Re: limit fires an extra query when offset is greater than 1

2022-07-10 Thread Jeremy Evans
On Sun, Jul 10, 2022 at 1:51 AM ashwin k wrote: > Not sure if first query can be ignored? > Not sure what you mean by "can be ignored". It's necessary to get the columns, and you need to know the columns to create the second query. Thanks, Jeremy > > On Sat, 9 Jul,

Re: limit fires an extra query when offset is greater than 1

2022-07-09 Thread Jeremy Evans
On Fri, Jul 8, 2022 at 9:41 PM ashwin k wrote: > Limit fires an extra query when the offset is more than 1. I created a > temp table and executed the query > DB[:temp].limit(3,3).all > > *First it executed this query* > START SELECT * FROM (SELECT * FROM "TEMP") "T1" WHERE (ROWNUM <= 1) > - END

Re: many_to_many with multiple right_key / right_primary_key values combined with OR instead of AND

2022-07-06 Thread Jeremy Evans
probably want to use the :graph_only_conditions option. Thanks, Jeremy > > On Wednesday, July 6, 2022 at 12:56:13 PM UTC-5 Jeremy Evans wrote: > >> On Wed, Jul 6, 2022 at 10:38 AM Matt Culpepper >> wrote: >> >>> Hey Jeremy, I'm trying to set up a relati

Re: many_to_many with multiple right_key / right_primary_key values combined with OR instead of AND

2022-07-06 Thread Jeremy Evans
On Wed, Jul 6, 2022 at 10:38 AM Matt Culpepper wrote: > Hey Jeremy, I'm trying to set up a relationship in a model that generates > SQL like the following join with an OR between the conditions. > > SELECT * FROM table1 INNER JOIN table2 ON (("table2"."resource_id" = > "table1"."an_id") OR

Re: Count the number of DB operations within a block

2022-06-24 Thread Jeremy Evans
On Fri, Jun 24, 2022 at 1:25 PM Mark Allen wrote: > Specifically, I'm trying to do this exact thing, but with Sequel instead > of ActiveRecord > > > https://github.com/rmosolgo/graphql-ruby/blob/master/guides/dataloader/testing.md#testing-dataloader-sources > > On Friday, June 24, 2022 at

Re: select only one field

2022-06-18 Thread Jeremy Evans
On Fri, Jun 17, 2022 at 11:15 AM Thiebo wrote: > or this is better : User.where(email:'myem...@zemail.com').get(:id) > This is probably what you want. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this

Re: Hooks are ignored using add_ methods.

2022-06-07 Thread Jeremy Evans
On Tue, Jun 7, 2022 at 8:05 AM Michał Gilewski wrote: > Hi, I'm trying to create a simple plugin that should set the value for the > column for the Sequel::Model. I noticed that when I'm trying to assign > records using add_ method all the hooks are omitted for the join model. > It's

Re: select sum as

2022-06-07 Thread Jeremy Evans
On Mon, Jun 6, 2022 at 10:06 PM Thiebo wrote: > Hello, > > I'm trying to do this SQL request (postgresql) : > > select SUM (montant) AS solde FROM entrees WHERE account_id = 1 and > date_de_valeur >= '2022-02-01' and date_de_valeur < '2022-03-01' > > Reading the documentation on virtual rows, I

Re: SSL security error

2022-06-03 Thread Jeremy Evans
On Thu, Jun 2, 2022 at 10:47 PM prathibha sumanth < prathibha.suma...@gmail.com> wrote: > Hi, > > I am connecting to database using Sequel.connect(db_connection_params) and > db_connection_param hash has following details, > db_connection_params = {:adapter=>'', :host=>server_ip, :port=>'', >

Re: select join as

2022-05-28 Thread Jeremy Evans
On Sat, May 28, 2022 at 2:00 PM Thiebo wrote: > I have one table "data" > >Column | > -+ > id| > account_id| > categorie_id | > amount | > > > And a table "categories" > >Column | > -+ > id

Re: Help writing with #explain syntax

2022-05-20 Thread Jeremy Evans
On Fri, May 20, 2022 at 10:06 AM fake farm wrote: > Hello, > > I am running `#insert` and it runs well for certain rows, but not others. > My DB connection is: > > ``` > @db_primary ||= Sequel.connect(adapter: :snowflake, drvconnect: > PRIMARY_DB) > table =

Re: _add method in associated tables

2022-05-07 Thread Jeremy Evans
On Fri, May 6, 2022 at 11:48 PM Thiebo wrote: > Hi everyone, > > I have these classes: > > class User < Sequel::Model > one_to_one :password > one_to_many :old_password > end > > class Password < Sequel::Model(:user_password_hashes) > many_to_one :user > end > > that correspond to the

Re: Want to know about `multi_update` ?

2022-04-26 Thread Jeremy Evans
On Tue, Apr 26, 2022 at 12:30 PM Kenneth Leung wrote: > Hi Jeremy, > > I tried your given example but failed with the following message. > "NoMethodError: undefined method `values' for > # is this an adapter-specific error? > From what I understand, DB is derived from Sequel::Database, but I

Re: Custom dataset when doing association_join

2022-04-13 Thread Jeremy Evans
On Wed, Apr 13, 2022 at 7:21 AM Martín Fernández wrote: > Hello, > > We stumbled upon a bug in our system due to a misunderstanding on how > custom datasets work when they are defined in models. > > We have the following example: > > ``` > class User > one_to_many :active_role_assignments,

Re: Why doesn't add_column :field, :boolean, index: true create an index?

2022-03-27 Thread Jeremy Evans
On Sun, Mar 27, 2022 at 3:34 PM aryk@gmail.com wrote: > When I create a new table I can put: > > create_table :foo do > column :bar, TrueClass, index: true > end > > and it creates an index, but "index: true" doesn't work with add_column > and instead doesn't throw any error, so you think

Re: Right syntax across 2 tables/models...

2022-02-27 Thread Jeremy Evans
On Sun, Feb 27, 2022 at 2:03 PM Bromley Jones wrote: > Hello > > Very new to Sequel and Ruby, so bear with > > The idea is to return model instances of the table_1 model where the id's > of table_1 do not exist in table_2 where another_id has a value. This is so > I can use those instances and

Re: Are nested function calls supported in Virutal Row Blocks?

2022-02-24 Thread Jeremy Evans
On Thu, Feb 24, 2022 at 3:47 PM Tim Tilberg wrote: > Today I was scripting out some DB maintenance tasks on SQL Server, and was > leveraging a query similar to: > > SELECT DISTINCT create_ts > FROM #{table} > WHERE create_ts < DATEADD(MONTH, -2, GETDATE()) > > I initially thought "Hey, what does

Re: Select specific columns from joined table

2022-02-22 Thread Jeremy Evans
On Tue, Feb 22, 2022 at 7:19 AM cra...@gmail.com wrote: > I'm trying to explicitly specify columns from two related models: > dataset = TableA > .where(table_a_column_a: 'foo') > .select(:table_a_column_b,:ambiguous_column) > .join(:table_b, table_a_id: :table_b_id) >

Re: How do I define a subset?

2022-02-16 Thread Jeremy Evans
On Wed, Feb 16, 2022 at 6:14 AM cra...@gmail.com wrote: > I'm trying to define a subset in a Model: > > class User < Sequel::Model > subset :active, Sequel.~(:inactive) > # proc > subset :name, -> (name) { where( Sequel.like(:username, > "%#{params[:name]}%") ) } > end > > When I attempt to use

Re: ORA-01000: maximum open cursors exceeded

2022-01-30 Thread Jeremy Evans
On Sun, Jan 30, 2022 at 1:47 AM Dylan Camilleri wrote: > Hi, > > Want to add some notes. Did some further reading on the issue. If a jdbc > callable statement is started on a jdbc connection object. > > Say: cs = Conn.prepareCall() > > Then it must be put into a begin / end block and under

Re: ORA-01000: maximum open cursors exceeded

2022-01-28 Thread Jeremy Evans
On Fri, Jan 28, 2022 at 12:54 AM Dylan Camilleri wrote: > Hi Jeremy! > > I am encountering this error using sequel with jdbc connected to oracle. > Is there a way I can commit / control the amount of open cursors? > > Caused by: > oracle.jdbc.OracleDatabaseException: ORA-01000: maximum open

Re: Filtering on a pg_enum[] column

2022-01-14 Thread Jeremy Evans
On Fri, Jan 14, 2022 at 9:29 AM 'Mike Pastore' via sequel-talk < sequel-talk@googlegroups.com> wrote: > Hi Jeremy, > > I have an `agent_role' enum type in my Postgres database, and a table with > a `roles' column, type `agent_role[]'. I'd like to filter records in this > table where the `roles'

Re: "Just created" plugin

2021-12-30 Thread Jeremy Evans
On Thu, Dec 30, 2021 at 12:51 PM tr...@upserver24.com wrote: > The use case is to know if current instance of the model was created, we > pass model instance to many services which sometimes need to run additional > actions if new record is just created, we can't have in after_create > callback

Re: "Just created" plugin

2021-12-30 Thread Jeremy Evans
On Wed, Dec 29, 2021 at 8:47 AM tr...@upserver24.com wrote: > Hi, > > We found this tiny useful plugin that allows to detect if model instance > was just created: > > ``` > module Sequel > module Plugins > module JustCreated > module InstanceMethods > def after_create >

Re: automatically destroy an object upon remove_association

2021-12-25 Thread Jeremy Evans
On Sat, Dec 25, 2021 at 10:53 PM jubishop wrote: > I would like to have an item automatically destroyed when a necessary > association has been removed via a call to a `remove_association` method. > I have achieved this right now with an extra bit of markup that looks like > this: > > ```ruby >

Re: Update a model instance with a database function.

2021-12-24 Thread Jeremy Evans
On Fri, Dec 24, 2021 at 9:47 AM Sébastien Lamy wrote: > Hi! > > I have a model "Adherent" correspondint to a table "adherents" in my > Postgres database. In this table, when I create a row from my app, I want > to set the "creator_id" column to same value as id. With Sequel the > folowing

Re: Sequel.pg_array(array) not working with .save_changes

2021-12-17 Thread Jeremy Evans
On Fri, Dec 17, 2021 at 6:59 AM Remtech Industries < remtechindustries...@gmail.com> wrote: > When I use the .save_changes method with Sequel.pg_array(array), the > changes are not saved to the database. > > patch '/issue/:id' do > issue = Issue[params[:id]] > issue.operator =

Re: How to merge datasets?

2021-12-13 Thread Jeremy Evans
On Mon, Dec 13, 2021 at 10:29 AM Tiago Cardoso wrote: > A segunda-feira, 13 de dezembro de 2021 à(s) 18:12:19 UTC, Jeremy Evans > escreveu: > >> On Mon, Dec 13, 2021 at 9:03 AM Tiago Cardoso >> wrote: >> >>> .intersect is definitely not covering my use-c

Re: How to merge datasets?

2021-12-13 Thread Jeremy Evans
On Mon, Dec 13, 2021 at 9:03 AM Tiago Cardoso wrote: > .intersect is definitely not covering my use-case. > Could you explain why? For the example you gave, results should be identical. > I'd be for a simple Dataset#merge_where, but as you said, it's relatively > simple to do it. My only

Re: How to merge datasets?

2021-12-13 Thread Jeremy Evans
On Mon, Dec 13, 2021 at 5:58 AM Tiago Cardoso wrote: > Hi, > > I'd like to know if there's a "public API" way of merging two datasets. > Something like, having the following: > > ``` > ds1 = db[table1].where(a: 1) > ds2 = db[table2].where(b: 2) > > # I'd like > ds1.merge(ds2) #=> would merge as

Re: SQLite3 json serializer and naked

2021-12-12 Thread Jeremy Evans
On Sun, Dec 12, 2021 at 2:16 PM jaso...@gmail.com wrote: > I'm experimenting using SQLite with some json APIs. Since there's no > out-of-the-box support for json columns, I'm storing loosely-structured > data as json in a Text column using the serialization plugin: > > plugin :serialization >

Re: How can I get a row count of a dataset that has bind parameters?

2021-12-11 Thread Jeremy Evans
On Sat, Dec 11, 2021 at 12:02 PM Michael Davis wrote: > Here is snippit of code that is trying to select qualifying rows from a > Movies table that has a Title column using bind parameters: > > Sequel.connect({ adapter: :sqlite, database: './tests/data/test.db' }) do > |db| > ds =

Re: Switch to GitHub Discussions?

2021-11-30 Thread Jeremy Evans
On Friday, November 19, 2021 at 2:51:40 PM UTC-8 Jeremy Evans wrote: > I'm leaning toward supporting both GitHub Discussions and Google Groups, > though having GitHub Discussions be the preferred place. Google Groups can > be interacted with purely through email without any acco

Re: Is there exists a easy way to clear all sequel annotate whichgenerated by sequel-annotate gem?

2021-11-24 Thread Jeremy Evans
Not currently. If you are interested in that, I'll consider 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

Re: many_to_one association with dataset modification in block

2021-11-23 Thread Jeremy Evans
On Tue, Nov 23, 2021 at 8:56 AM Robert Pawlas wrote: > Hello, > > I've just tried to make many_to_one association with some additions in > block, like in this example: > > class Car < Sequel::Model(DB[:default][:cars]) > many_to_one :company, class: 'Company', read_only: true, do |ds| >

Re: DB.run("UPDATE investing_latest_news SET title = title, preview = preview;") not work done invoke with roda request?

2021-11-22 Thread Jeremy Evans
On Mon, Nov 22, 2021 at 11:42 AM Billy Zheng wrote: > > Hi, Jeremy, i upload a .png attachment, please have a look, that is a > screenshot on zhparser github repo. > https://github.com/amutu/zhparser#%E8%87%AA%E5%AE%9A%E4%B9%89%E8%AF%8D%E5%BA%93-21 > > that may explain why Sequel not work with

Re: DB.run("UPDATE investing_latest_news SET title = title, preview = preview;") not work done invoke with roda request?

2021-11-22 Thread Jeremy Evans
On Mon, Nov 22, 2021 at 10:55 AM Billy Zheng wrote: > > I cannot see why the first two would cause a problem, but maybe the last > one does? You can turn that off via the :use_iso_date_format=>false option > when > setting up your Database connection. > > I consider not caused by those option,

  1   2   3   4   5   6   7   8   9   10   >