Skip to content

Commit

Permalink
fix: quote table names
Browse files Browse the repository at this point in the history
  • Loading branch information
frectonz committed Jun 17, 2024
1 parent a7921b9 commit 06dc708
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
16 changes: 8 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl TheDB {
for name in table_names {
let name = name?;
let count =
conn.query_row(&format!("SELECT count(*) FROM {name}"), (), |r| {
conn.query_row(&format!("SELECT count(*) FROM '{name}'"), (), |r| {
r.get::<_, i32>(0)
})?;

Expand Down Expand Up @@ -259,7 +259,7 @@ impl TheDB {
for name in table_names {
let name = name?;
let count =
conn.query_row(&format!("SELECT count(*) FROM {name}"), (), |r| {
conn.query_row(&format!("SELECT count(*) FROM '{name}'"), (), |r| {
r.get::<_, i32>(0)
})?;

Expand Down Expand Up @@ -296,7 +296,7 @@ impl TheDB {
)?;

let row_count =
conn.query_row(&format!("SELECT count(*) FROM {name}"), (), |r| {
conn.query_row(&format!("SELECT count(*) FROM '{name}'"), (), |r| {
r.get::<_, i32>(0)
})?;

Expand All @@ -318,7 +318,7 @@ impl TheDB {
)?;

let has_primary_key =
conn.query_row(&format!("PRAGMA table_info({name})"), [], |r| {
conn.query_row(&format!("PRAGMA table_info('{name}')"), [], |r| {
r.get::<_, i32>(5)
})? == 1;
let index_count = if has_primary_key {
Expand All @@ -327,7 +327,7 @@ impl TheDB {
index_count
};

let mut columns = conn.prepare(&format!("PRAGMA table_info({name})"))?;
let mut columns = conn.prepare(&format!("PRAGMA table_info('{name}')"))?;
let column_count = columns.query_map((), |r| r.get::<_, String>(1))?.count() as i32;

Ok(responses::Table {
Expand All @@ -351,16 +351,16 @@ impl TheDB {
.conn
.call(move |conn| {
let first_column =
conn.query_row(&format!("PRAGMA table_info({name})"), [], |r| {
conn.query_row(&format!("PRAGMA table_info('{name}')"), [], |r| {
r.get::<_, String>(1)
})?;

let offset = (page - 1) * ROWS_PER_PAGE;
let mut stmt = conn.prepare(&format!(
r#"
SELECT *
FROM {name}
ORDER BY {first_column}
FROM '{name}'
ORDER BY '{first_column}'
LIMIT {ROWS_PER_PAGE}
OFFSET {offset}
"#
Expand Down
68 changes: 34 additions & 34 deletions ui/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,60 @@

// This file is auto-generated by TanStack Router

import { createFileRoute } from "@tanstack/react-router";
import { createFileRoute } from '@tanstack/react-router'

// Import Routes

import { Route as rootRoute } from "./routes/__root";
import { Route as rootRoute } from './routes/__root'

// Create Virtual Routes

const TablesLazyImport = createFileRoute("/tables")();
const QueryLazyImport = createFileRoute("/query")();
const IndexLazyImport = createFileRoute("/")();
const TablesLazyImport = createFileRoute('/tables')()
const QueryLazyImport = createFileRoute('/query')()
const IndexLazyImport = createFileRoute('/')()

// Create/Update Routes

const TablesLazyRoute = TablesLazyImport.update({
path: "/tables",
path: '/tables',
getParentRoute: () => rootRoute,
} as any).lazy(() => import("./routes/tables.lazy").then((d) => d.Route));
} as any).lazy(() => import('./routes/tables.lazy').then((d) => d.Route))

const QueryLazyRoute = QueryLazyImport.update({
path: "/query",
path: '/query',
getParentRoute: () => rootRoute,
} as any).lazy(() => import("./routes/query.lazy").then((d) => d.Route));
} as any).lazy(() => import('./routes/query.lazy').then((d) => d.Route))

const IndexLazyRoute = IndexLazyImport.update({
path: "/",
path: '/',
getParentRoute: () => rootRoute,
} as any).lazy(() => import("./routes/index.lazy").then((d) => d.Route));
} as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))

// Populate the FileRoutesByPath interface

declare module "@tanstack/react-router" {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
"/": {
id: "/";
path: "/";
fullPath: "/";
preLoaderRoute: typeof IndexLazyImport;
parentRoute: typeof rootRoute;
};
"/query": {
id: "/query";
path: "/query";
fullPath: "/query";
preLoaderRoute: typeof QueryLazyImport;
parentRoute: typeof rootRoute;
};
"/tables": {
id: "/tables";
path: "/tables";
fullPath: "/tables";
preLoaderRoute: typeof TablesLazyImport;
parentRoute: typeof rootRoute;
};
'/': {
id: '/'
path: '/'
fullPath: '/'
preLoaderRoute: typeof IndexLazyImport
parentRoute: typeof rootRoute
}
'/query': {
id: '/query'
path: '/query'
fullPath: '/query'
preLoaderRoute: typeof QueryLazyImport
parentRoute: typeof rootRoute
}
'/tables': {
id: '/tables'
path: '/tables'
fullPath: '/tables'
preLoaderRoute: typeof TablesLazyImport
parentRoute: typeof rootRoute
}
}
}

Expand All @@ -71,7 +71,7 @@ export const routeTree = rootRoute.addChildren({
IndexLazyRoute,
QueryLazyRoute,
TablesLazyRoute,
});
})

/* prettier-ignore-end */

Expand Down

0 comments on commit 06dc708

Please sign in to comment.