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

String values are returned as interned symbols #35

Closed
lokedhs opened this issue Nov 22, 2017 · 5 comments
Closed

String values are returned as interned symbols #35

lokedhs opened this issue Nov 22, 2017 · 5 comments

Comments

@lokedhs
Copy link

lokedhs commented Nov 22, 2017

When performing a select query which returns string values, those strings are returned in the form of symbols. What is worse is that these symbols are interned, which can easily cause performance problems in Emacs since the obarray will be filled up.

A better solution would be to return plain strings instead of symbols.

@lokedhs
Copy link
Author

lokedhs commented Nov 22, 2017

Here is some example code to reproduce this:

ELISP> (obarray-get obarray "this-symbol-is-not-interned")
nil
ELISP> (emacsql-with-connection (db (emacsql-sqlite "/tmp/foo.db"))
         (emacsql db "select 'this-symbol-is-not-interned'"))
((this-symbol-is-not-interned))

ELISP> (obarray-get obarray "this-symbol-is-not-interned")
this-symbol-is-not-interned

@skeeto
Copy link
Contributor

skeeto commented Nov 22, 2017 via email

@lokedhs
Copy link
Author

lokedhs commented Nov 22, 2017

I see. Apparently I had misunderstood the purpose of emacsql. I'm building a generic SQL tool in Emacs, and I figured that I could build that on top of emacsql.

Do you have any desire to expand emacsql to support this use-case? If not, I will build something separate.

@skeeto
Copy link
Contributor

skeeto commented Nov 22, 2017 via email

@LewWadoo
Copy link

LewWadoo commented May 2, 2021

To convert returned symbol list to a string I had to write a function:

(defun convert-list-to-string (list)
  "Convert list to string."
  (let* ((string-with-parenthesis (format "%S" list))
     (end (- (length string-with-parenthesis) 2)))
    (substring string-with-parenthesis 2 end)))

@tarsius tarsius closed this as completed Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants