Try this:

...
(jdbc/with-quoted-identifiers \"
    (jdbc/update-or-insert-values ...))
...

clojure.java.jdbc supports generic naming strategies that specify how to
wrap column names (going into JDBC) and how to convert column names (back
to Clojure keys on the way out of JDBC).

Different databases use different quoting conventions - MySQL supports
`column` for example. I think MS SQL Server supports [column] so you can do
that by passing a two element vector to with-quoted-identifiers [\[ \]]

By default, c.j.jdbc converts column names to lowercase keywords when
returning a resultset but you can use a naming strategy to override that
and return column names as-is, for example.

See the docs for more details:

http://clojure.github.com/java.jdbc/#clojure.java.jdbc/with-naming-strategy

Sean


On Tue, Feb 5, 2013 at 11:15 PM, <a...@bitlimn.com> wrote:

> @Andy: Sorry, I didn't know the proper channel, I'll post it there.
>
> I don't control the column names. They're imported from an excel
> spreadsheet or assigned by the client I'm writing the app for. From
> experience, it is certainly *possible*, at least to add these columns.
> Currently I just have a function that "escapes" the user input, replacing
> special characters with lookalikes (i.e. space with an underscore).
>
> On Tuesday, February 5, 2013 10:42:50 PM UTC-8, Sean Corfield wrote:
>
>> Andy's right on process... but as maintainer of clojure.java.jdbc, I
>> have to ask: why on earth do you have column names containing spaces
>> or & or other weird characters? That's a serious question: how do you
>> get into that situation?
>>
>> I'm not saying clojure.java.jdbc can't be updated to support it, I'm
>> just questioning whether it should...
>>
>> On Tue, Feb 5, 2013 at 7:32 PM, Andy Fingerhut <andy.fi...@gmail.com>
>> wrote:
>> > You can create a ticket for java.jdbc here if you wish that describes
>> the problem and what you think will fix it.  Then any of the 500+ Clojure
>> contributors can take a shot at fixing it:
>> >
>> >     
>> > http://dev.clojure.org/jira/**browse/JDBC<http://dev.clojure.org/jira/browse/JDBC>
>> >
>> > Andy
>> >
>> > On Feb 5, 2013, at 7:07 PM, al...@bitlimn.com wrote:
>> >
>> >> Hey all,
>> >>
>> >> I've been using clojure.java.jdbc to write a simple database app. When
>> I use the `update-or-insert-values` function, I get an SQLException thrown
>> whenever my column names have special characters in them (like a space or
>> an ampersand). I think the solution is in line 908: the column-strs should
>> be quoted before calling `interpose`. If you do `(map #(str "\"" %1 "\"")
>> column-strs)` that should do it?
>> >>
>> >> I can get around this by just writing my own version, but I wanted to
>> patch it for everybody. I was told in #clojure that I can't? Anyways, I'm
>> going to try to get in contact with the maintainer, but if anyone here has
>> contributing rights, and would like to patch it, you have my thanks.
>> >>
>> >> --semisight
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@googlegroups.com
>> > Note that posts from new members are moderated - please be patient with
>> your first post.
>> > To unsubscribe from this group, send email to
>> > clojure+u...@**googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>> > ---
>> > You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to clojure+u...@**googlegroups.com.
>> > For more options, visit 
>> > https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>.
>>
>> >
>> >
>>
>>
>>
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>> World Singles, LLC. -- http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to