Module: Sqlx::Json
- Defined in:
- runtime/sqlx/json.rbs,
runtime/sqlx/json.rb
Class Method Summary collapse
-
.decode(text) ⇒ Object
the logical value a column holds: nil is SQL NULL and a String is the serialized text.
-
.encodable?(value) ⇒ Boolean
whether JSON can represent this value on its own terms: nil, true/false, a String, a finite number, or a nested Array/Hash of those (Hash keys may be Symbols; they read back as Strings).
-
.encode(value) ⇒ String?
the logical value a column holds: nil is SQL NULL and everything else is JSON text, so
decodereads it back equal.
Class Method Details
.decode(text) ⇒ Object
the logical value a column holds: nil is SQL NULL and a String is the serialized text. Anything else is a caller bug — the logical value is already in hand, so there is nothing to decode, and guessing would hide it. Malformed text raises through the same door (see the file header for why the parser's own class stays inside).
88 |
# File 'runtime/sqlx/json.rb', line 88
def self.decode: (untyped text) -> untyped
|
.encodable?(value) ⇒ Boolean
whether JSON can represent this value on its own terms: nil, true/false, a
String, a finite number, or a nested Array/Hash of those (Hash keys may be
Symbols; they read back as Strings). This is the predicate encode
enforces, exposed because it is the precondition a caller holding
untrusted input asks BEFORE putting the value in a column — the
label?-beside-label shape.
28 |
# File 'runtime/sqlx/json.rb', line 28
def self.encodable?: (untyped value) -> bool
|
.encode(value) ⇒ String?
the logical value a column holds: nil is SQL NULL and everything else is
JSON text, so decode reads it back equal. A value JSON cannot represent
raises instead of being to_sd into the column — a Time never arrives as
text by accident. JSON null is not distinguishable from SQL NULL here: a
caller that needs the literal writes it directly.
66 |
# File 'runtime/sqlx/json.rb', line 66
def self.encode: (untyped value) -> String?
|