Skip to content

Bind ActiveRecord::Schema.define + class < ActiveRecord::Base (stage-4b hard PASS)#105

Merged
tannevaled merged 2 commits into
mainfrom
fix/ar-schema-define
Jul 2, 2026
Merged

Bind ActiveRecord::Schema.define + class < ActiveRecord::Base (stage-4b hard PASS)#105
tannevaled merged 2 commits into
mainfrom
fix/ar-schema-define

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Closes the last web-app run-conformance gap: the idiomatic ActiveRecord ORM route now runs end to end, so TestStage4bActiveRecord flips from SKIP to a hard PASS.

What ran before / runs now

The AR binding (#102) supported establish_connection + Model.where(...).to_a/count/create. The stage-4b conformance app additionally needs ActiveRecord::Schema.define, the create_table DSL, class User < ActiveRecord::Base, create!, and where(...).order(...).to_a rendered through ERB. Those now work.

Added to the binding

  • ActiveRecord::Schema.define { create_table … } — runs a DDL block whose create_table renders CREATE TABLE (+ CREATE INDEX) and executes it through the connected sqlite3 adapter (the same path create/where use). Column DSL: string/integer/float/boolean/text/datetime/timestamp/date/time/binary/decimal/bigint, timestamps, references/belongs_to, generic column, t.index, primary_key, and the id:/primary_key: create_table options; plus add_index/add_column/execute.
  • class User < ActiveRecord::Base as a working model — table name inferred via activerecord.Tableize (or set with self.table_name =), answering all/where/order/count/first/find/create/create! by lazily resolving a cached model and reusing the existing chainable Relation. Records expose their columns as dynamic reader/writer accessors so an AR-loaded row renders through u.name.

Library

Uses new Tableize/Pluralize inflectors and TableDef.PrimaryKey added in go-ruby-activerecord (go-ruby-activerecord/activerecord#1), re-pinned here.

Asserted stage-4b response

GET /users?min=26status=200, body=<ul><li>amy (30)</li><li>cat (40)</li></ul>.

Tests

100% coverage on the new binding code; full internal/vm suite green under TZ=UTC; schema Ruby source uses no host paths (Windows-safe). Depends on go-ruby-activerecord/activerecord#1 (merge + tag/re-pin before this).

🤖 Generated with Claude Code

tannevaled and others added 2 commits July 3, 2026 00:24
Extend the go-ruby-activerecord binding so the idiomatic Rails-style ORM
route runs end to end (conformance stage 4b flips SKIP -> hard PASS):

- ActiveRecord::Schema.define { create_table … } runs a DDL block whose
  create_table renders CREATE TABLE (+ CREATE INDEX) through the connected
  sqlite3 adapter — the same adapter Model.create/where already use. The
  create_table column DSL covers string/integer/float/boolean/text/
  datetime/timestamp/date/time/binary/decimal/bigint, timestamps,
  references/belongs_to, the generic column, t.index, primary_key, and the
  id:/primary_key: options; add_index/add_column/execute round it out.
- A `class User < ActiveRecord::Base` subclass becomes a working model:
  its table name is inferred via activerecord.Tableize (or set with
  self.table_name =) and it answers all/where/order/count/first/find/
  create/create! by lazily resolving a cached model and reusing the same
  chainable Relation surface. Records answer their columns as dynamic
  reader/writer accessors (method_missing/respond_to_missing?), so an
  AR-loaded row renders through the u.name calls a Rails view uses.

Uses go-ruby-activerecord's Tableize/Pluralize + TableDef.PrimaryKey
(added there, re-pinned). 100% coverage on the new binding; full vm suite
green under TZ=UTC; schema Ruby source is Windows-safe (no host paths).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled tannevaled merged commit c29a8b1 into main Jul 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant