Skip to content

Instantly share code, notes, and snippets.

View yahonda's full-sized avatar

Yasuo Honda yahonda

View GitHub Profile
test=# CREATE TABLE "posts" ("id" bigserial primary key, "title" character varying);
CREATE TABLE
test=# ALTER TABLE "posts" ADD CONSTRAINT posts_const CHECK (char_length(title) >= 5) NOT VALID;
ALTER TABLE
test=# CREATE TABLE "comments" ("id" bigserial primary key, "body" text, CONSTRAINT comments_const CHECK (char_length(body) >= 5) NOT VALID);
CREATE TABLE
test=# SELECT conname, convalidated FROM pg_constraint WHERE contype = 'c'
and conname in('posts_const','comments_const');
conname | convalidated
----------------+--------------
$ git clone https://github.com/rails/rails
cd rails
git clone https://github.com/yahonda/buildkite-config -b disable_innodb_snapshot_isolation .buildkite/
RUBY_IMAGE=ruby:3.3 docker-compose -f .buildkite/docker-compose.yml build base &&
CI=1 MYSQL_IMAGE=mariadb:latest docker-compose -f .buildkite/docker-compose.yml run mariadb runner activerecord 'rake db:mysql:rebuild test:mysql2'
Cloning into 'rails'...
remote: Enumerating objects: 892424, done.
remote: Counting objects: 100% (915/915), done.
remote: Compressing objects: 100% (495/495), done.
remote: Total 892424 (delta 574), reused 656 (delta 417), pack-reused 891509 (from 1)
$ git clone https://github.com/rails/rails
cd rails
git clone https://github.com/rails/buildkite-config .buildkite/
RUBY_IMAGE=ruby:3.3 docker compose -f .buildkite/docker-compose.yml build base &&
CI=1 MYSQL_IMAGE=mariadb:11.6.2 docker compose -f .buildkite/docker-compose.yml run mariadb runner activerecord 'rake db:mysql:rebuild test:mysql2'
Cloning into 'rails'...
remote: Enumerating objects: 891547, done.
remote: Counting objects: 100% (65/65), done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 891547 (delta 24), reused 29 (delta 4), pack-reused 891482 (from 1)
$ git clone https://github.com/rails/rails
cd rails
git clone https://github.com/rails/buildkite-config .buildkite/
RUBY_IMAGE=ruby:3.3 docker compose -f .buildkite/docker-compose.yml build base &&
CI=1 MYSQL_IMAGE=mariadb:11.6.1-rc docker compose -f .buildkite/docker-compose.yml run mariadb runner activerecord 'rake db:mysql:rebuild test:mysql2'
Cloning into 'rails'...
remote: Enumerating objects: 891547, done.
remote: Counting objects: 100% (65/65), done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 891547 (delta 24), reused 29 (delta 4), pack-reused 891482 (from 1)
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "webmock"
# gem "webmock", git: "https://github.com/Earlopain/webmock.git", branch: "net-http-adapter-ruby-3.4"
end
p RUBY_VERSION
WebMock.enable!
class C
class_eval "def throw_syntax_error; eval %(
'abc' + pluralize 'def'
); end", "lib/file.rb", 42
end
c = C.new
c.throw_syntax_error
$ ruby -v
ruby 3.4.0dev (2024-09-10T02:50:49Z master 3db2782748) [x86_64-linux]
```
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching stringio 3.1.1
Using sqlite3 2.0.4 (was 2.0.0)
/rails/activerecord/lib/arel/collectors/composite.rb:28: warning: the block passed to 'Arel::Collectors::Bind#add_bind' defined at /rails/activerecord/lib/arel/collectors/bind.rb:16 may be ignored
/rails/activesupport/lib/active_support/testing/strict_warnings.rb:35:in 'ActiveSupport::RaiseWarnings#warn': /rails/activerecord/lib/arel/collectors/composite.rb:28: warning: the block passed to 'Arel::Collectors::Bind#add_bind' defined at /rails/activerecord/lib/arel/collectors/bind.rb:16 may be ignored (ActiveSupport::RaiseWarnings::WarningError)
	from /rails/activerecord/lib/arel/collectors/composite.rb:28:in 'Arel::Collectors::Composite#add_bind'
	from /rails/activerecord/lib/arel/visitors/to_sql.rb:761:in 'Arel::Visitors::ToSql#visit_Arel_Nodes_BindParam'
	from /rails/activerecord/lib/arel/visitors/visitor.rb:30:in 'Arel::Visitors::Visitor#visit'
	from /rails/activerecord/lib/arel/visitors/to_sql.rb:654:in 'Arel::Visitors::ToSql#visit_Arel_Nodes_Equality'
	from /rails/activerecord/lib/arel/visitors/vis
  • Run non prepared statement using psql
$ bin/psql -d test
psql (17devel)
Type "help" for help.

test=# \d
                 List of relations
 Schema |         Name         |   Type   |  Owner
--------+----------------------+----------+---------
#!/usr/bin/env ruby

require 'pg'

# Output a table of current connections to the DB
conn = PG.connect( dbname: 'test' )
conn.exec('DROP TABLE IF EXISTS posts')