Questions tagged [sequel-gem]

Sequel is a ruby gem providing a simple, flexible, powerful and lightweight SQL database access toolkit for Ruby

29 questions
0
votes
1 answer

Sequel: how to pass variable to select block?

I need to calculate users count inside of select query. Here is my SQL snippet SELECT count(id) FROM demo.users WHERE year_id = 'c4c62a9d-801f-4573-92a8-aa0a8589200a' I use it inside of CASE count(DISTINCT assigned_lessons.id) WHEN 0 THEN…
arturtr
  • 1,115
  • 9
  • 18
0
votes
1 answer

Is instance.attribute_name and instance[:attribute_name] exactly the same for sequel model attribute (db column)?

I use Rails 5.1.4, Sequel 5.9.0, Postgre, rack-mini-profiler (the latest), sequel-rails 1.0.1. I'm trying to figure out why my application is slow. Here's what I found. I made a simple query to get posts using @posts = Post.all and got ~150. And I…
okliv
  • 3,909
  • 30
  • 47
0
votes
1 answer

Sequel and Postgres array of enum

I have enum_cars. I have table user with column: own_cars: enum_cars[] When I get User model and fetch own_cars field for instance, I have: user.own_cars #=> "{Ford}" String I connected DB.extension :pg_array and Sequel.extension…
QNester
  • 463
  • 4
  • 9
0
votes
1 answer

Sequel + ADO + Puma is not threading queries

We have a website running in Windows Server 2008 + SQLServer 2008 + Ruby + Sinatra + Sequel/Puma We've developed an API for our website. When the access points are requested by many clients, at the same time, the clients start getting RequestTimeout…
0
votes
1 answer

Simple Local Database Solution for Ruby?

I'm attempting to write a simple Ruby/Nokogiri scraper to get event information from multiple pages and then output it to a CSV that is attached to an email sent out weekly. I have completed the scraping components and the CSV component and it's…
Nicholas S
  • 25
  • 6
0
votes
1 answer

Sequel validations in concerns

I have a Sequel model like this: class User < Sequel::Model include Notificatable def validate super validates_presence [:email] end end # concerns/notificatable.rb module Notificatable extend ActiveSupport::Concern included…
Jack Owels
  • 149
  • 1
  • 9
0
votes
2 answers

Custom Table Mapping with Sequel gem

Been spinning my wheels. How would one specify a custom table mapping with the sequel gem? I've done the following init.rb OTHER_DB = Sequel.connect(:adapter => 'tinytds', :host => 'host1', :database => 'mydatabase', :user => 'myuser', :password =>…
bgura
  • 860
  • 15
  • 33
0
votes
2 answers

Rails 4.2 Sequel Model - Form_for on new not working as expected

I created a new Rails 4.2 project, set up the Sequel Gem as per docs and ran the following command to set up my first section of the project: rails generate scaffold Author nom_de_plume:string real_name:string email_address:string…
MichelV69
  • 1,247
  • 6
  • 18
0
votes
2 answers

Sequel unique validation across multiple columns

I'm trying to add a validates_unique validation using the Sequel gem and a MySQL database. I'd like it to fail validation if the value of column2 matches an existing value in column3, so something like the following (non-working)…
Drew Ogryzek
  • 350
  • 3
  • 17
0
votes
2 answers

Sequel relations and SQL functions

I am using Ruby Sequel and I need to find the total amount spent by a customer since a specific date. This code is working: customer = Customer.where(username: params[:username]).first unless customer exit end Purchases.where(customer:…
Florin Asăvoaie
  • 849
  • 1
  • 6
  • 20
0
votes
1 answer

Specify a foreign key in Sequel model

I have two models: Foo: class Foo < Sequel::Model (:FOO_TABLE) set_primary_key [:KEY] # has many Bars one_to_many :bars end Bar: class Bar < Sequel::Model (:BAR_TABLE) # compound key set_primary_key [:KEY,:NBR] # belongs to Foo …
craig
  • 25,664
  • 27
  • 119
  • 205
0
votes
1 answer

Many to many and one to many association between same models

I am creating a simple Sinatra app, using Sequel for my ORM. Most of the data revolves around users and events where: An event can have many users, one of which is the "owner". Users can have many events, one or many of which they "own". Here is…
Nick Tomlin
  • 28,402
  • 11
  • 61
  • 90
0
votes
1 answer

Sequel Model Transaction block is not rollbacked when save fails(because of validation) and raise_on_save_failure = false

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 =…
Deepak Agrawal
  • 136
  • 1
  • 7
0
votes
1 answer

Error updating Ruby gem sequel_pg

when I try to install the Ruby gem sequel_pg I get the following error meassage: ~$ sudo gem update Updating installed gems Updating sequel_pg Building native extensions. This could take a while... ERROR: Error installing sequel_pg: ERROR: Failed…
dikdirk
  • 11
  • 3
1
2