spec
|--- apis #do not put into controllers folder.
|--- your_api_test_spec.rb
|--- controllers
|--- models
|--- factories
|--- views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rom-sql" | |
require "rom-repository" | |
require "byebug" | |
module Persistence | |
module Relations | |
class Configurations < ROM::Relation[:sql] | |
gateway :alternate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hi, this is the setup of my problem. | |
# The thing is that I'm working in a legacy database where primary keys are not autoincrement ids, | |
# They're strings and are named <<entity>>_id. | |
# Also some foreign keys are named diferrently like the one for zones in journeys relation, that is named | |
# start_zone_id | |
# | |
# The queries that I pretend to implement are explained in comments in the repository class. | |
class Interval < ROM::Relation[sql] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi, this is the setup of my problem. | |
The thing is that I'm working in a legacy database where primary keys are not autoincrement ids, | |
They're strings and are named <<entity>>_id. | |
Also some foreign keys are named diferrently like the one for zones in journeys relation, that is named | |
start_zone_id | |
The queries that I pretend to implement are explained in comments in the repository class. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#spec/rom_factories/users.rb | |
RomFactory::Builder.define do |b| | |
b.factory(relation: :users, name: :user_1) do |f| | |
f.id "ID1" | |
f.name "John" | |
f.surname "Doe" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'repository' | |
module Persistence | |
module Couch | |
module Repositories | |
class Agencies < Repository[:agencies] | |
def find_id(id) | |
agencies.find_id(id) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config.time_zone = 'Madrid' | |
# Como en este caso queremos utilizar la hora local en la base de datos | |
config.active_record.default_timezone = :local | |
config.active_record.time_zone_aware_attributes = false | |
config.time_zone = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*) as TotalRows from (SELECT TOP 1000000000 [repuestos].id FROM [repuestos] LEFT OUTER JOIN [consumos_reales] ON consumos_reales.repuesto_id = repuestos.id LEFT OUTER JOIN [consumos_previstos] ON consumos_previstos.repuesto_id = repuestos.id WHERE (consumos_reales.repuesto_id is not null OR consumos_previstos.repuesto_id is not null ) GROUP BY [repuestos].id ORDER BY MIN(codigo)) tally | |
SET NOCOUNT ON DECLARE @row_number TABLE (row int identity(1,1), id int) INSERT INTO @row_number (id) SELECT [repuestos].id FROM [repuestos] LEFT OUTER JOIN [consumos_reales] ON consumos_reales.repuesto_id = repuestos.id LEFT OUTER JOIN [consumos_previstos] ON consumos_previstos.repuesto_id = repuestos.id WHERE (consumos_reales.repuesto_id is not null OR consumos_previstos.repuesto_id is not null ) GROUP BY [repuestos].id ORDER BY MIN(codigo) SET NOCOUNT OFF SELECT id FROM ( SELECT TOP 30 * FROM ( SELECT TOP 60 * FROM @row_number ORDER BY row ) AS tmp1 ORDER BY row DESC ) AS tmp2 ORDER BY row | |
SELECT [repuestos].[i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ODBC::Error: S1090 (0) [unixODBC][Driver Manager]Invalid string or buffer length | |
from /home/jmcervera/.rvm/gems/ruby-1.8.7-p249/bundler/gems/2000-2005-adapter-d3b9c12b533892babd5c39aa1ae62cff0e27caf6-3.0.0.beta1/lib/active_record/connection_adapters/sqlserver_adapter.rb:335:in `initialize' | |
from /home/jmcervera/.rvm/gems/ruby-1.8.7-p249/bundler/gems/2000-2005-adapter-d3b9c12b533892babd5c39aa1ae62cff0e27caf6-3.0.0.beta1/lib/active_record/connection_adapters/sqlserver_adapter.rb:335:in `connect' | |
from /home/jmcervera/.rvm/gems/ruby-1.8.7-p249/bundler/gems/2000-2005-adapter-d3b9c12b533892babd5c39aa1ae62cff0e27caf6-3.0.0.beta1/lib/active_record/connection_adapters/sqlserver_adapter.rb:335:in `connect' | |
from /home/jmcervera/.rvm/gems/ruby-1.8.7-p249/bundler/gems/2000-2005-adapter-d3b9c12b533892babd5c39aa1ae62cff0e27caf6-3.0.0.beta1/lib/active_record/connection_adapters/sqlserver_adapter.rb:186:in `initialize' | |
from /home/jmcervera/.rvm/gems/ruby-1.8.7-p249/bundler/gems/2000-2005-adapter-d3b9c12b533892babd5c39aa1a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rubygems DNS is temporarily down, put this into your /etc/hosts to install gems, | |
# but don't forget to remove the entries once their DNS is back up again | |
72.4.120.124 rubygems.org | |
207.171.181.231 production.s3.rubygems.org | |
216.137.45.24 production.cf.rubygems.org |
NewerOlder