sequel Questions
2
Solved
I have a fairly complex case statement that works in MySQL:
SELECT # rest of code omitted
CASE WHEN code = 'a' THEN 'x'
WHEN code IN ('m', 'n') THEN 'y'
WHEN class IN ('p', 'q') AND amount < ...
4
Solved
I'm having trouble working through a gem load error on AWS Lambda.
{
"errorMessage": "LoadError: libpq.so.5: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ru...
Harriman asked 23/1, 2019 at 15:38
2
Solved
I'm pretty new to Sequel and I'm scratching my head trying to figure out how to get Sequel's API to generate the following trivial SQL:
select f.* from first f
join second s on f.second_id = s.i...
2
Solved
I see that the Sequel gem supports migrations here, but I don't see any type of generator documented. Does one exist; or should I be manually creating all of my migrations (or alternately creating ...
8
Solved
I am using PostgreSQL via the Ruby gem 'sequel'.
I'm trying to round to two decimal places.
Here's my code:
SELECT ROUND(AVG(some_column),2)
FROM table
I get the following error:
PG::Error:...
Faxun asked 28/10, 2012 at 21:15
5
Solved
I keep getting an Encoding::UndefinedConversionError - "\xC2" from ASCII-8BIT to UTF-8 every time I try to convert a hash into a JSON string. I tried with [.encode | .force_encoding]([&qu...
2
I still can't find a solution to fix an association factory issue when using Sequel.
I have two models relying on one_to_many, which is the same as has_manyin Active Record, and many_to_one, which...
Cetacean asked 24/4, 2017 at 14:4
3
Solved
I'm looking to do something like
User.select(...).where(:name != nil)
without writing something like
User.select(...).to_a.find_all {|user| user.name}
I can select for null values, but not fo...
2
Solved
I am using Sinatra and Sequel with PostgreSQL.
After authentication, I want to welcome the user by printing their name but I cannot get only the value of the user's name from the database, it com...
Donnettedonni asked 11/6, 2013 at 8:13
3
Solved
I just want to get the last_insert_id() using Ruby's Sequel:
insertret = @con.run("INSERT INTO `wv_persons` ( `id` ) VALUES ( NULL )")
pp insertret.inspect # returns "nil", expected that..
last_in...
3
Given the code below, how can default values be defined for the Model.
(let's say the default for :name should be 'Thing').
require 'pp'
require 'sequel'
DB = Sequel.sqlite
DB.create_table :ite...
2
Solved
I have a method that selects all the rows from my table like this:
smtp_status_raw = my_table.select(:message, :is_valid, :hostname).map { |h| h.values }
This returns an array that's like this:
...
1
Solved
I am running into issues using database cleaner with sequel and sqlite foreign key constraints. Specifically, I am using the :truncation strategy with Capybara integration tests.
For the given sam...
Opprobrium asked 24/12, 2015 at 20:13
2
Solved
I'm trying to implement a form to search through the title of my posts.
This is the controller code:
post '/search' do
@results = Post.all(:Title.like => "%#{params[:query]}%")
erb :layout
en...
0
These are the options I see that can help solve "Rails 5 - Object Relation Impedence and how to structure multiple inherited classes/tables" TL;DR - the Object Table Impedance ORM problem.
Abstra...
Naamann asked 16/9, 2016 at 5:55
2
Solved
I have a model based on Sequel and Oracle adapter:
class Operation < Sequel::Model(DB[:operations])
end
If I try to create a record using Oracle's sequence.nextval as primary key:
Operation...
5
Solved
In the Sequel ORM for Ruby, the Dataset class has an all method which produces an Array of row hashes: each row is a Hash with column names as keys.
For example, given a table T:
a b c
----------...
2
Solved
I'm trying to use the Ruby Sequel::Model ORM functionality for a web service, in which every user's data is stored in a separate MySQL database. There may be thousands of users and thus databases. ...
Dartmouth asked 11/2, 2014 at 15:45
4
Solved
I just started using Sequel in a really small Sinatra app. Since I've got only one DB table, I don't need to use models.
I want to update a record if it exists or insert a new record if it does no...
2
Solved
In SQL in order to avoid getting a NULL value, I can use the "coalesce" function to substitute it like so:
SELECT COALESCE(some_column, 0) FROM some_table;
But I can't find any way to do the s...
3
Solved
Using Sequel I'd like to create an UPDATE statement like the following (from Postgres docs)
UPDATE employees SET sales_count = sales_count + 1 FROM accounts
WHERE accounts.name = 'Acme Corporatio...
3
Is it possible to make many updates in a single call using Sequel?
For instance, making about 200 updates could take several minutes on my server, but if I forge a single SQL query it runs in a ma...
Spleenwort asked 3/5, 2012 at 14:28
2
Solved
There is this mysql database I'm trying to connect to. DataMapper fetches everything nicely in UTF-8 but Sequel always returns strings in ASCII-8bit which produces errors with .to_json.
I have tri...
2
Solved
Here is my code for joining two tables:
DB.from(:sources).join(:payloads, :source_id => :id)
The table names are :sources, :payloads.
The problem is that there is an :id column in payloads w...
3
Solved
How I can I avoid having validation for update while having it for create? For instance:
I wish to have an image field to have presence validation on create. But want to avoid it in edit and assum...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.