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

Convert integers to strings #8

Closed
simonw opened this issue Dec 1, 2019 · 0 comments
Closed

Convert integers to strings #8

simonw opened this issue Dec 1, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@simonw
Copy link
Owner

simonw commented Dec 1, 2019

Consider this query:

https://pge-outages.simonwillison.net/pge-outages?sql=select%0D%0A++id+||+%27%27+as+atom_title%2C%0D%0A++id+||+%27%27+as+atom_id%2C%0D%0A++id+||+%27%27+as+atom_content%2C%0D%0A++datetime(outageStartTime%2C+%22unixepoch%22)+||+%22Z%22+as+atom_updated%0D%0Afrom%0D%0A++outages%0D%0Aorder+by%0D%0A++id+desc%0D%0Alimit%0D%0A++101

select
  id || '' as atom_title,
  id || '' as atom_id,
  id || '' as atom_content,
  datetime(outageStartTime, "unixepoch") || "Z" as atom_updated
from
  outages
order by
  id desc
limit
  101

I had to use the '' || id pattern to avoid an error relating to strings v.s. integers: https://pge-outages.simonwillison.net/pge-outages.atom?sql=select%0D%0A++id+as+atom_title%2C%0D%0A++id+as+atom_id%2C%0D%0A++id+as+atom_content%2C%0D%0A++datetime%28outageStartTime%2C+%22unixepoch%22%29+%7C%7C+%22Z%22+as+atom_updated%0D%0Afrom%0D%0A++outages%0D%0Aorder+by%0D%0A++id+desc%0D%0Alimit%0D%0A++101

Error 500: Argument must be bytes or unicode, got 'int'

@simonw simonw added the bug Something isn't working label Dec 1, 2019
@simonw simonw closed this as completed in 0a7182f Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant