mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-10 02:34:20 +01:00
Merge 'bind/javascript: Fix presentation mode disabling logic' from Diego Reis
Presentation mode disabling logic was ~obviously~ wrong (my bad), it's fixed now. Closes #2125
This commit is contained in:
@@ -185,27 +185,61 @@ dualTest.both("Statement.all() [pluck]", async (t) => {
|
||||
t.deepEqual(stmt.pluck().all(), expected);
|
||||
});
|
||||
|
||||
dualTest.onlySqlitePasses("Statement.all() [default safe integers]", async (t) => {
|
||||
const db = t.context.db;
|
||||
db.defaultSafeIntegers();
|
||||
const stmt = db.prepare("SELECT * FROM users");
|
||||
const expected = [
|
||||
[1n, "Alice", "alice@example.org"],
|
||||
[2n, "Bob", "bob@example.com"],
|
||||
];
|
||||
t.deepEqual(stmt.raw().all(), expected);
|
||||
});
|
||||
dualTest.both(
|
||||
"Statement.raw() [passing false should disable raw mode]",
|
||||
async (t) => {
|
||||
const db = t.context.db;
|
||||
|
||||
dualTest.onlySqlitePasses("Statement.all() [statement safe integers]", async (t) => {
|
||||
const db = t.context.db;
|
||||
const stmt = db.prepare("SELECT * FROM users");
|
||||
stmt.safeIntegers();
|
||||
const expected = [
|
||||
[1n, "Alice", "alice@example.org"],
|
||||
[2n, "Bob", "bob@example.com"],
|
||||
];
|
||||
t.deepEqual(stmt.raw().all(), expected);
|
||||
});
|
||||
const stmt = db.prepare("SELECT * FROM users");
|
||||
const expected = [
|
||||
{ id: 1, name: "Alice", email: "alice@example.org" },
|
||||
{ id: 2, name: "Bob", email: "bob@example.com" },
|
||||
];
|
||||
t.deepEqual(stmt.raw(false).all(), expected);
|
||||
},
|
||||
);
|
||||
|
||||
dualTest.both(
|
||||
"Statement.pluck() [passing false should disable pluck mode]",
|
||||
async (t) => {
|
||||
const db = t.context.db;
|
||||
|
||||
const stmt = db.prepare("SELECT * FROM users");
|
||||
const expected = [
|
||||
{ id: 1, name: "Alice", email: "alice@example.org" },
|
||||
{ id: 2, name: "Bob", email: "bob@example.com" },
|
||||
];
|
||||
t.deepEqual(stmt.pluck(false).all(), expected);
|
||||
},
|
||||
);
|
||||
|
||||
dualTest.onlySqlitePasses(
|
||||
"Statement.all() [default safe integers]",
|
||||
async (t) => {
|
||||
const db = t.context.db;
|
||||
db.defaultSafeIntegers();
|
||||
const stmt = db.prepare("SELECT * FROM users");
|
||||
const expected = [
|
||||
[1n, "Alice", "alice@example.org"],
|
||||
[2n, "Bob", "bob@example.com"],
|
||||
];
|
||||
t.deepEqual(stmt.raw().all(), expected);
|
||||
},
|
||||
);
|
||||
|
||||
dualTest.onlySqlitePasses(
|
||||
"Statement.all() [statement safe integers]",
|
||||
async (t) => {
|
||||
const db = t.context.db;
|
||||
const stmt = db.prepare("SELECT * FROM users");
|
||||
stmt.safeIntegers();
|
||||
const expected = [
|
||||
[1n, "Alice", "alice@example.org"],
|
||||
[2n, "Bob", "bob@example.com"],
|
||||
];
|
||||
t.deepEqual(stmt.raw().all(), expected);
|
||||
},
|
||||
);
|
||||
|
||||
dualTest.onlySqlitePasses("Statement.raw() [failure]", async (t) => {
|
||||
const db = t.context.db;
|
||||
|
||||
@@ -450,11 +450,10 @@ impl Statement {
|
||||
|
||||
#[napi]
|
||||
pub fn pluck(&mut self, pluck: Option<bool>) {
|
||||
if let Some(false) = pluck {
|
||||
self.presentation_mode = PresentationMode::None;
|
||||
}
|
||||
|
||||
self.presentation_mode = PresentationMode::Pluck;
|
||||
self.presentation_mode = match pluck {
|
||||
Some(false) => PresentationMode::None,
|
||||
_ => PresentationMode::Pluck,
|
||||
};
|
||||
}
|
||||
|
||||
#[napi]
|
||||
@@ -464,11 +463,10 @@ impl Statement {
|
||||
|
||||
#[napi]
|
||||
pub fn raw(&mut self, raw: Option<bool>) {
|
||||
if let Some(false) = raw {
|
||||
self.presentation_mode = PresentationMode::None;
|
||||
}
|
||||
|
||||
self.presentation_mode = PresentationMode::Raw;
|
||||
self.presentation_mode = match raw {
|
||||
Some(false) => PresentationMode::None,
|
||||
_ => PresentationMode::Raw,
|
||||
};
|
||||
}
|
||||
|
||||
#[napi]
|
||||
|
||||
Reference in New Issue
Block a user