seesaw.core/table does not return strings

96 views
Skip to first unread message

Mortimer Cladwell

unread,
Jan 19, 2018, 5:45:08 PM1/19/18
to seesaw-clj
I have a Sqlite3 database with a "plate" table containing the field "plate_sys_name" defined as TEXT(30).  I query the contents of plate into a seesaw.core/table - all is fine.

User makes a  row(s) selection and I want to retrieve the selected row(s):
(println (value-at (select (to-root e)[:#tblplates]) (selection (select (to-root e) [:#tblplates]){:multi? true})))
pm
.core>  ({:format 96, :plate_seq_num 3, :plate_format_id 1, :rownum 8, :plate_sys_name PLT-3, :type assay, :plate_set_id 3, :id 3, :colnum 12, :project_id 3, :id_2 1})


Looks fine except that plate_sys_name is not quoted, clojure thinks it's an undefined variable, and if I try to do anything eg.:

(get (value-at (select (to-root e)[:#tblplates]) (selection (select (to-root e) [:#tblplates]){:multi? true})) :plate_sys_name)
pm
.core>

2. Unhandled clojure.lang.Compiler$CompilerException
   
Error compiling src/pm/core.clj at (127:6)

1. Caused by java.lang.RuntimeException
   
Unable to resolve symbol: PLT-1 in this context

How do I get the original types out of the table?
Thanks
Mortimer

Dave Ray

unread,
Jan 22, 2018, 3:57:57 PM1/22/18
to seesa...@googlegroups.com
Hi,

It's not entirely clear what's going on from your example. `println` doesn't quote strings. Try `prn` instead if you want to see strins quoted.

Dave

--
You received this message because you are subscribed to the Google Groups "seesaw-clj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seesaw-clj+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mortimer Cladwell

unread,
Jan 23, 2018, 5:18:49 PM1/23/18
to seesaw-clj
"value-at" on a row(s) selection of seesaw.core/table returns something that looks like a list of maps with unquoted values in the map:

({:a x :b y :c z})

My mistake was not realizing that this can not be manipulated as a list until it is quoted.  Once quoted, problem solved:

(str (get (first '({:a x :b y :c z})) :a)) => "x"

Thanks
Mortimer
To unsubscribe from this group and stop receiving emails from it, send an email to seesaw-clj+...@googlegroups.com.

abacus

unread,
Jan 23, 2018, 9:34:40 PM1/23/18
to seesaw-clj
Welllll, if the x in {:a x} is a string, then you got lucky there was no space in that string!  Be careful round-tripping data structures that print has shorn of double-quotes.  Also, note that quoting the list makes x be interpreted as a symbol, not a string...  In short, measurement error may be creeping in and complicating matters for you.  And with that diagnosis, I would urge you to visit the Clojurians Slack channel!  Or the Clojure google group.  Lots more helpers.
Reply all
Reply to author
Forward
0 new messages