ON "post_subscriptions"."user_id" = "post_subscriptions_2"."source_id" AND "post_subscriptions_2"."user_id" = "post_subscriptions"."source_id" суббота, 2 ноября 13 г.
ON "post_subscriptions"."user_id" = "post_subscriptions_2"."source_id" AND "post_subscriptions_2"."user_id" = "post_subscriptions"."source_id" ... And fun! суббота, 2 ноября 13 г.
Relational Algebra, there are no queries per se; everything is either a relation or an operation on a relation» http://web.archive.org/web/20120718093140/http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/ Why Arel? by Nathan Kallen суббота, 2 ноября 13 г.
you can build your own ORM with it, focusing on innovative object and collection modeling as opposed to database compatibility and query generation.» https://github.com/rails/arel суббота, 2 ноября 13 г.
you can build your own ORM with it, focusing on innovative object and collection modeling as opposed to database compatibility and query generation.» суббота, 2 ноября 13 г.
you can build your own ORM with it, focusing on innovative object and collection modeling as opposed to database compatibility and query generation.» суббота, 2 ноября 13 г.
Bond'> SELECT "staff".* FROM "staff" WHERE ( ("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4 != 0) ) Do it simple and self-descriptive Not on a low-level суббота, 2 ноября 13 г.
8 != 0 OR 'staff'."role_mask" & 4 != 0) )} Any mistakes? ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "." LINE 1: ..." WHERE (("staff"."role_mask" & 8 != 0 OR 'staff'."role_mas... суббота, 2 ноября 13 г.
8 != 0 OR 'staff'."role_mask" & 4 != 0) )} Any mistakes? ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "." LINE 1: ..." WHERE (("staff"."role_mask" & 8 != 0 OR 'staff'."role_mas... Arrr!!! Not again! суббота, 2 ноября 13 г.
your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.* FROM "staff" WHERE (("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4' at line 1: SELECT "staff".* FROM "staff" WHERE (("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4 != 0)) ActiveRecord::Base.connection.execute %q{ SELECT "staff".* FROM "staff" WHERE ( ("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4 != 0) )} суббота, 2 ноября 13 г.
in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.* FROM "staff" WHERE (("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4' at line 1: SELECT "staff".* FROM "staff" WHERE (("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4 != 0)) ActiveRecord::Base.connection.execute %q{ SELECT "staff".* FROM "staff" WHERE ( ("staff"."role_mask" & 8 != 0 OR "staff"."role_mask" & 4 != 0) )} суббота, 2 ноября 13 г.
condition_for_roles(roles, options) r = roles.dup condition = role_present(r.shift, options[:column]) r.inject(condition) do |cond, role| cond.or(role_present(role, options[:column])) end end суббота, 2 ноября 13 г.
role_present(role, column) (Arel::Nodes::InfixOperation.new "&", self.arel_table[column.to_sym], (2**Staff::ROLES[role.to_sym]) ).not_eq(0) end суббота, 2 ноября 13 г.
schema (we had ~20 tables and thousands of join’s) • want to port the app to different DBs (our social intranet was running on PostgreSQL, MySQL, whatever they had) суббота, 2 ноября 13 г.
schema (we had ~20 tables and thousands of join’s) • want to port the app to different DBs (our social intranet was running on PostgreSQL, MySQL, whatever they had) • describe complex things with simple code суббота, 2 ноября 13 г.
(full_name = 'O''Connor')" Good. It escapes. What if you don’t have ActiveRecord at ALL? query = "INSERT OR REPLACE INTO postcodes(code, lat,lon) VALUES ( '#{code}', #{'%.5f' % lat}, #{'%.5f' % lon});" суббота, 2 ноября 13 г.
(full_name = 'O''Connor')" Good. It escapes. What if you don’t have ActiveRecord at ALL? query = "INSERT OR REPLACE INTO postcodes(code, lat,lon) VALUES ( '#{code}', #{'%.5f' % lat}, #{'%.5f' % lon});" oh yes... very straightforward! суббота, 2 ноября 13 г.
(full_name = 'O''Connor')" Good. It escapes. What if you don’t have ActiveRecord at ALL? query = "INSERT OR REPLACE INTO postcodes(code, lat,lon) VALUES ( '#{code}', #{'%.5f' % lat}, #{'%.5f' % lon});" oh yes... very straightforward! INSERT OR REPLACE INTO postcodes(code, lat,lon) VALUES ('2606 O'MALLEY', -35.35434, 149.10677); : near "MALLEY": syntax error суббота, 2 ноября 13 г.
system total real AR: 29.200000 2.690000 31.890000 ( 79.686113) Generated SQL: 1.920000 0.420000 2.340000 ( 11.347266) RAW SQL: 1.040000 0.370000 1.410000 ( 8.810435) суббота, 2 ноября 13 г.