mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 03:54:21 +01:00
Merge pull request #200 from benclmnt/case-insensitive-cols
This commit is contained in:
@@ -163,7 +163,7 @@ impl PseudoTable {
|
||||
|
||||
pub fn add_column(&mut self, name: &str, ty: Type, primary_key: bool) {
|
||||
self.columns.push(Column {
|
||||
name: name.to_string(),
|
||||
name: normalize_ident(name),
|
||||
ty,
|
||||
primary_key,
|
||||
});
|
||||
@@ -259,7 +259,7 @@ fn create_table(
|
||||
primary_key = true;
|
||||
}
|
||||
cols.push(Column {
|
||||
name,
|
||||
name: normalize_ident(&name),
|
||||
ty,
|
||||
primary_key,
|
||||
});
|
||||
|
||||
@@ -576,13 +576,15 @@ pub fn resolve_ident_qualified<'a>(
|
||||
select: &'a Select,
|
||||
cursor_hint: Option<usize>,
|
||||
) -> Result<(usize, Type, usize, bool)> {
|
||||
let ident = normalize_ident(ident);
|
||||
let table_name = normalize_ident(table_name);
|
||||
for join in &select.src_tables {
|
||||
match join.table {
|
||||
Table::BTree(ref table) => {
|
||||
let table_identifier = match join.alias {
|
||||
Some(alias) => alias.clone(),
|
||||
None => table.name.to_string(),
|
||||
};
|
||||
let table_identifier = normalize_ident(match join.alias {
|
||||
Some(alias) => alias,
|
||||
None => &table.name,
|
||||
});
|
||||
if table_identifier == *table_name {
|
||||
let res = table
|
||||
.columns
|
||||
@@ -612,14 +614,15 @@ pub fn resolve_ident_table<'a>(
|
||||
select: &'a Select,
|
||||
cursor_hint: Option<usize>,
|
||||
) -> Result<(usize, Type, usize, bool)> {
|
||||
let ident = normalize_ident(ident);
|
||||
let mut found = Vec::new();
|
||||
for join in &select.src_tables {
|
||||
match join.table {
|
||||
Table::BTree(ref table) => {
|
||||
let table_identifier = match join.alias {
|
||||
Some(alias) => alias.clone(),
|
||||
None => table.name.to_string(),
|
||||
};
|
||||
let table_identifier = normalize_ident(match join.alias {
|
||||
Some(alias) => alias,
|
||||
None => &table.name,
|
||||
});
|
||||
let res = table
|
||||
.columns
|
||||
.iter()
|
||||
|
||||
@@ -5,19 +5,19 @@ pub(crate) mod where_clause;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use expr::{build_select, maybe_apply_affinity, translate_expr};
|
||||
use crate::function::{AggFunc, Func};
|
||||
use crate::pager::Pager;
|
||||
use crate::schema::{Column, PseudoTable, Schema, Table};
|
||||
use crate::translate::select::{ColumnInfo, LoopInfo, Select, SrcTable};
|
||||
use crate::sqlite3_ondisk::{DatabaseHeader, MIN_PAGE_CACHE_SIZE};
|
||||
use crate::types::{OwnedRecord, OwnedValue};
|
||||
use crate::util::normalize_ident;
|
||||
use crate::vdbe::{BranchOffset, Insn, Program, ProgramBuilder};
|
||||
use crate::translate::select::{ColumnInfo, LoopInfo, Select, SrcTable};
|
||||
use crate::translate::where_clause::{
|
||||
evaluate_conditions, translate_conditions, translate_where, Inner, Left, QueryConstraint,
|
||||
};
|
||||
use crate::types::{OwnedRecord, OwnedValue};
|
||||
use crate::util::normalize_ident;
|
||||
use crate::vdbe::{BranchOffset, Insn, Program, ProgramBuilder};
|
||||
use anyhow::Result;
|
||||
use expr::{build_select, maybe_apply_affinity, translate_expr};
|
||||
use sqlite3_parser::ast::{self, Literal};
|
||||
|
||||
struct LimitInfo {
|
||||
@@ -426,10 +426,10 @@ fn translate_tables_end(
|
||||
}
|
||||
|
||||
fn translate_table_open_cursor(program: &mut ProgramBuilder, table: &SrcTable) -> LoopInfo {
|
||||
let table_identifier = match table.alias {
|
||||
Some(alias) => alias.clone(),
|
||||
None => table.table.get_name().to_string(),
|
||||
};
|
||||
let table_identifier = normalize_ident(match table.alias {
|
||||
Some(alias) => alias,
|
||||
None => &table.table.get_name(),
|
||||
});
|
||||
let cursor_id = program.alloc_cursor_id(Some(table_identifier), Some(table.table.clone()));
|
||||
let root_page = match &table.table {
|
||||
Table::BTree(btree) => btree.root_page,
|
||||
@@ -539,10 +539,10 @@ fn translate_table_star(
|
||||
target_register: usize,
|
||||
cursor_hint: Option<usize>,
|
||||
) {
|
||||
let table_identifier = match table.alias {
|
||||
Some(alias) => alias.clone(),
|
||||
None => table.table.get_name().to_string(),
|
||||
};
|
||||
let table_identifier = normalize_ident(match table.alias {
|
||||
Some(alias) => alias,
|
||||
None => &table.table.get_name(),
|
||||
});
|
||||
let table_cursor = program.resolve_cursor_id(&table_identifier, cursor_hint);
|
||||
let table = &table.table;
|
||||
for (i, col) in table.columns().iter().enumerate() {
|
||||
|
||||
@@ -22,3 +22,7 @@ do_execsql_test realify {
|
||||
do_execsql_test select-add {
|
||||
select u.age + 1 from users u where u.age = 91 limit 1;
|
||||
} {92}
|
||||
|
||||
do_execsql_test case-insensitive-columns {
|
||||
select u.aGe + 1 from USERS u where U.AGe = 91 limit 1;
|
||||
} {92}
|
||||
|
||||
Reference in New Issue
Block a user