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

Mojolicious::Lite Example Fails (Single vs. Double Quotes) #15

Closed
DabeDotCom opened this issue Jul 22, 2020 · 5 comments
Closed

Mojolicious::Lite Example Fails (Single vs. Double Quotes) #15

DabeDotCom opened this issue Jul 22, 2020 · 5 comments

Comments

@DabeDotCom
Copy link

DabeDotCom commented Jul 22, 2020

This example:

use Mojolicious::Lite;
use Mojo::SQLite;
 
helper sqlite => sub { state $sql = Mojo::SQLite->new('sqlite:test.db') };
 
get '/' => sub {
  my $c  = shift;
  my $db = $c->sqlite->db;
  $c->render(json => $db->query('select datetime("now","localtime") as now')->hash);
};
 
app->start;

Failed for me with DBD::SQLite::db prepare_cached failed: no such column: now

Interestingly, however, it worked when I switched around the single- and double-quotes:

  $c->render(json => $db->query("select datetime('now','localtime') as now")->hash);

PS: The command-line interface didn't seem to have a problem with the quotes:

prompt% sqlite3 --version
3.28.0 2019-04-16 19:49:53 884b4b7e502b4e991677b53971277adfaf0a04a284f8e483e2553d0f83156b50

prompt% echo 'select datetime("now", "localtime") as now' | sqlite3 /tmp/test.db 
2020-07-22 18:08:37
@DabeDotCom
Copy link
Author

Config follows:

Summary of my perl5 (revision 5 version 18 subversion 1) configuration:
   
  Platform:
    osname=darwin, osvers=13.0.0, archname=darwin-2level
    uname='darwin triton.parabon.com 13.0.0 darwin kernel version 13.0.0: thu sep 19 22:22:27 pdt 2013; root:xnu-2422.1.72~6release_x86_64 x86_64 '
    config_args='-de -Dprefix=/Users/dabe/perl5/perlbrew/perls/perl-5.18.1 -Aeval:scriptdir=/Users/dabe/perl5/perlbrew/perls/perl-5.18.1/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O3',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldb -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                        PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
                        USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
  Built under darwin
  Compiled at Dec 10 2013 17:45:12
  %ENV:
    PERL5LIB="/fs/triton/Users/dabe/Documents/Parabon/Website/perl5/lib/perl5"
    PERLBREW_BASHRC_VERSION="0.78"
    PERLBREW_HOME="/Users/dabe/.perlbrew"
    PERLBREW_MANPATH="/Users/dabe/perl5/perlbrew/perls/perl-5.18.1/man"
    PERLBREW_PATH="/Users/dabe/perl5/perlbrew/bin:/Users/dabe/perl5/perlbrew/perls/perl-5.18.1/bin"
    PERLBREW_PERL="perl-5.18.1"
    PERLBREW_ROOT="/Users/dabe/perl5/perlbrew"
    PERLBREW_VERSION="0.78"
    PERL_LOCAL_LIB_ROOT="/fs/triton/Users/dabe/Documents/Parabon/Website/perl5"
    PERL_MB_OPT="--install_base "/fs/triton/Users/dabe/Documents/Parabon/Website/perl5""
    PERL_MM_OPT="INSTALL_BASE=/fs/triton/Users/dabe/Documents/Parabon/Website/perl5"
  @INC:
    /fs/triton/Users/dabe/Documents/Parabon/Website/perl5/lib/perl5/darwin-2level
    /fs/triton/Users/dabe/Documents/Parabon/Website/perl5/lib/perl5
    /Users/dabe/perl5/perlbrew/perls/perl-5.18.1/lib/site_perl/5.18.1/darwin-2level
    /Users/dabe/perl5/perlbrew/perls/perl-5.18.1/lib/site_perl/5.18.1
    /Users/dabe/perl5/perlbrew/perls/perl-5.18.1/lib/5.18.1/darwin-2level
    /Users/dabe/perl5/perlbrew/perls/perl-5.18.1/lib/5.18.1
    .

And here are the dependencies it tried to install:

ExtUtils-Config-0.008
Test-Harness-3.42
ExtUtils-Helpers-0.026
ExtUtils-InstallPaths-0.012
Mojo-SQLite-3.003
Module-Build-Tiny-0.039
Test-Needs-0.002006
URI-1.76
SQL-Abstract-1.87
Sub-Uplevel-0.2800
Test-Exception-0.43
Test-Without-Module-0.20
Clone-Choose-0.010
Hash-Merge-0.301
Try-Tiny-0.30
Test-Fatal-0.014
Sub-Quote-2.006006
MRO-Compat-0.13
Test-Warn-0.36
Test-Simple-1.302175
Test-Deep-1.130
Module-Runtime-0.016
Class-Method-Modifiers-2.13
Role-Tiny-2.001004
Moo-2.004000
DBI-1.643
DBD-SQLite-1.64
URI-db-0.19
URI-Nested-0.10

@Grinnz
Copy link
Owner

Grinnz commented Jul 22, 2020

This is intentionally disabled, see https://sqlite.org/quirks.html#double_quoted_string_literals_are_accepted

@DabeDotCom
Copy link
Author

So should the Mojo::SQLite docs be updated?

(I can whip up a PR if you'd like, but I'm guessing by the time I fork the repo and whatnot, you could already have it fixed...)

@Grinnz Grinnz closed this as completed in 9b4101e Jul 22, 2020
@Grinnz
Copy link
Owner

Grinnz commented Jul 22, 2020

Docs will be updated in the next release, thanks!

@DabeDotCom
Copy link
Author

No, sir... Thank YOU! 🙏 ;-D

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

2 participants