Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue related to quoted identifier in Pgsql. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/sql_printers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ and string_of_value (value, _) =
| Cast (v, t) ->
sprintf "CAST(%s AS %s)" (string_of_value v) (string_of_atom_type t)
| Field ((Row (row_name, _), _), fields) ->
sprintf "%s.%s" (keyword_safe row_name)
sprintf "%s.\"%s\"" (keyword_safe row_name)
(String.concat path_separator (List.map keyword_safe fields))
| Field (v, _) ->
failwith (Printf.sprintf "string_of_value : invalid field access (%s)"
Expand All @@ -139,7 +139,7 @@ and string_of_value (value, _) =
| li -> " " ^ string_of_list string_of_value " " right)
| Case ([], default) -> string_of_value default
| Case (cases, default) ->
let string_of_case (cond, case) =
let string_of_case (cond, case) =
sprintf "WHEN %s THEN %s"
(string_of_value cond) (string_of_value case) in
sprintf "(CASE %s ELSE %s END)"
Expand All @@ -149,8 +149,9 @@ and string_of_from_item (row_name, table) =
sprintf "%s AS %s" (string_of_view table) (keyword_safe row_name)
and string_of_table (table : table) = string_of_table_name table.data.name
and string_of_table_name = function
| (None, table) -> keyword_safe table
| (Some schema, table) -> sprintf "%s.%s" (keyword_safe schema) (keyword_safe table)
| (None, table) -> "\"" ^ (keyword_safe table) ^ "\""
| (Some schema, table) -> sprintf "%s.\"%s\"" (keyword_safe schema) (keyword_safe table)

and string_of_atom =
let quote printer value = sprintf "E'%s'" (printer value) in
function
Expand Down Expand Up @@ -206,4 +207,3 @@ let rec string_of_query = function
(string_of_assoc set)
(string_of_from from)
(string_of_where where)