Class: Sequel::D1::Dataset

Inherits:
Sequel::Dataset show all
Includes:
SQLite::DatasetMethods
Defined in:
lib/sequel/adapters/d1.rb

Overview

Dataset — delegated to shared sqlite dialect entirely.

Instance Method Summary collapse

Methods inherited from Sequel::Dataset

#__homura_orig_literal_append, #_all, #each, #literal_append, #single_value, #sql_string_origin, #with_sql_each, #with_sql_first, #with_sql_single_value

Instance Method Details

#fetch_rows(sql, &block) ⇒ Object

fetch_rows on the D1 adapter materialises the full result set via ‘execute` (which `.__await__`s the D1 Promise) and yields each row synchronously to the caller’s block. Keeping the yield loop sync-only is critical: Opal’s async-function compiler cannot propagate Ruby block-exit throws (break / next / return) across an ‘await` boundary —trying results in LocalJumpError. Upstream Sequel’s with_sql_first / single_value rely on ‘break`/`return` from inside this loop, so we keep it strictly sync here.



271
272
273
274
275
276
277
278
279
# File 'lib/sequel/adapters/d1.rb', line 271

def fetch_rows(sql, &block)
  # Opal compiles this method to an async function because of
  # `.__await__`. After the await completes we hold a plain
  # Array, so the each below iterates synchronously — Ruby
  # block-exit throws (break/next/return) bind to this local
  # each rather than to some outer async continuation.
  rows = execute(sql).__await__
  rows.each(&block)
end