mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
return row as reference to registers
This commit is contained in:
parent
5b7fcd27bd
commit
ee55116ca6
15 changed files with 166 additions and 67 deletions
20
cli/app.rs
20
cli/app.rs
|
@ -5,7 +5,7 @@ use crate::{
|
|||
opcodes_dictionary::OPCODE_DESCRIPTIONS,
|
||||
};
|
||||
use comfy_table::{Attribute, Cell, CellAlignment, Color, ContentArrangement, Row, Table};
|
||||
use limbo_core::{Database, LimboError, RefValue, Statement, StepResult};
|
||||
use limbo_core::{Database, LimboError, OwnedValue, RefValue, Statement, StepResult};
|
||||
|
||||
use clap::{Parser, ValueEnum};
|
||||
use rustyline::{history::DefaultHistory, Editor};
|
||||
|
@ -711,7 +711,7 @@ impl<'a> Limbo<'a> {
|
|||
match rows.step() {
|
||||
Ok(StepResult::Row) => {
|
||||
let row = rows.row().unwrap();
|
||||
for (i, value) in row.get_values().iter().enumerate() {
|
||||
for (i, value) in row.get_values().enumerate() {
|
||||
if i > 0 {
|
||||
let _ = self.writer.write(b"|");
|
||||
}
|
||||
|
@ -767,21 +767,21 @@ impl<'a> Limbo<'a> {
|
|||
let record = rows.row().unwrap();
|
||||
let mut row = Row::new();
|
||||
row.max_height(1);
|
||||
for (idx, value) in record.get_values().iter().enumerate() {
|
||||
for (idx, value) in record.get_values().enumerate() {
|
||||
let (content, alignment) = match value {
|
||||
RefValue::Null => {
|
||||
OwnedValue::Null => {
|
||||
(self.opts.null_value.clone(), CellAlignment::Left)
|
||||
}
|
||||
RefValue::Integer(_) => {
|
||||
OwnedValue::Integer(_) => {
|
||||
(format!("{}", value), CellAlignment::Right)
|
||||
}
|
||||
RefValue::Float(_) => {
|
||||
OwnedValue::Float(_) => {
|
||||
(format!("{}", value), CellAlignment::Right)
|
||||
}
|
||||
RefValue::Text(_) => {
|
||||
OwnedValue::Text(_) => {
|
||||
(format!("{}", value), CellAlignment::Left)
|
||||
}
|
||||
RefValue::Blob(_) => {
|
||||
OwnedValue::Blob(_) => {
|
||||
(format!("{}", value), CellAlignment::Left)
|
||||
}
|
||||
};
|
||||
|
@ -849,7 +849,7 @@ impl<'a> Limbo<'a> {
|
|||
match rows.step()? {
|
||||
StepResult::Row => {
|
||||
let row = rows.row().unwrap();
|
||||
if let Some(RefValue::Text(schema)) = row.get_values().first() {
|
||||
if let Ok(OwnedValue::Text(schema)) = row.get::<&OwnedValue>(0) {
|
||||
let _ = self.write_fmt(format_args!("{};", schema.as_str()));
|
||||
found = true;
|
||||
}
|
||||
|
@ -907,7 +907,7 @@ impl<'a> Limbo<'a> {
|
|||
match rows.step()? {
|
||||
StepResult::Row => {
|
||||
let row = rows.row().unwrap();
|
||||
if let Some(RefValue::Text(table)) = row.get_values().first() {
|
||||
if let Ok(OwnedValue::Text(table)) = row.get::<&OwnedValue>(0) {
|
||||
tables.push_str(table.as_str());
|
||||
tables.push(' ');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue