The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2015-08-07

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:32 meshl joined #mojo
00:50 sopanshewale joined #mojo
01:05 sawtooth joined #mojo
01:08 sopanshewale joined #mojo
01:12 zivester joined #mojo
01:37 thowe joined #mojo
01:38 sawtooth joined #mojo
02:41 noganex_ joined #mojo
03:05 kaare joined #mojo
03:59 absolut__ joined #mojo
04:01 Grinnz i may have found an issue that affects Mojo::Pg in trying to solve another issue in Mojo::SQLite... ill need to write up some tests for Pg
04:02 Grinnz but essentially... https://github.com/Grinnz/Mojo-SQLite/issues/2
04:03 Grinnz i have to test it, cause i don't know if prepare_cached works the same way in DBD::Pg
04:03 Grinnz (or even if finish does...)
04:04 Grinnz sometimes i think things would be easier if all of these database connectors weren't all developed for DBI :P
04:11 inokenty-w joined #mojo
04:29 mattastrophe joined #mojo
04:44 jontaylor_ joined #mojo
04:44 melo1 joined #mojo
05:48 sopanshewale joined #mojo
05:55 arpadszasz joined #mojo
06:00 Lee joined #mojo
06:05 jontaylor joined #mojo
06:16 amon joined #mojo
06:24 trone joined #mojo
06:24 oetiker joined #mojo
06:32 sopanshewale joined #mojo
06:57 dod joined #mojo
07:02 dod joined #mojo
07:03 dotandimet joined #mojo
07:34 Vandal joined #mojo
07:37 AndrewIsh joined #mojo
07:42 dotandimet joined #mojo
07:51 eseyman joined #mojo
08:05 arthas joined #mojo
08:14 batman Grinnz: https://metacpan.org/pod/Mojo::MySQL5 :)
08:15 dod joined #mojo
09:06 dotandimet joined #mojo
09:45 sh4 joined #mojo
10:29 punter joined #mojo
10:33 melo joined #mojo
11:04 rwp joined #mojo
11:53 neilhwatson joined #mojo
12:20 sri jberger: i'm still alive, just very busy
12:22 sri Grinnz: you screwed up callback handling in Mojo::SQLite
12:22 sri this needs to use Mojo::IOLoop->next_tick https://github.com/Grinnz/Mojo-SQLite/blob/master/lib/Mojo/SQLite/Database.pm#L72
12:23 sri you never ever invoke the callback right away
12:24 mattastrophe joined #mojo
12:24 sri always defer to the next reactor tick, or you get recursion problems and the like
12:32 sri Grinnz: oh, and no, the DESTROY is not a problem, because active statement handles are not reused
12:33 sri we use prepare_cached(..., 3), which creates a new statement handle if the cached one is still active
12:34 nic joined #mojo
12:37 nic My code has the full path to an html.ep file, and just wants to render it, the same as if it was underneat 'templates'
12:38 nic but without adding its location to the rendering search path
12:38 nic Is the best way to do that as an inline template?
12:40 nic $c->render(inline => slurp $filepath)
12:45 jberger sri: o/
12:45 jberger Or
12:45 jberger "A wild sri appears"
12:46 jberger nic: I suppose that would work
12:46 jberger Why not have it in your templates?
12:46 hernan605 joined #mojo
12:46 jberger You can add more directories to search if you want to keep them separate
12:53 nic I want stuff in the path to be stuff that behaves like normal templates and its accessibility is controlled purely by the router
12:54 nic but for these files, there's some complicated business logic and the controller decides what files will get plucked out and translated into something rendered
12:54 nic I suspect $c->render(inline => $file) isn't currently working for me because $file is absolute
12:55 nic but there's a templating example in the Guide which looks helpful
12:57 nic I suppose this controller is trying to be a mini router, specific to one area of the app
12:58 Grinnz sri, maybe that doesn't work correctly in DBD::SQLite then
12:59 nic On a vaguely related note, $renderer->get_data_template looks very useful for templates/layouts you want to be private to a specific controller
13:01 Grinnz sri, and thanks for the tip :) the callback handling is mostly an afterthought but next_tick is a better idea
13:03 Grinnz nic, "inline" is a template that is a string, not a filename to a template
13:03 Grinnz you could do inline => slurp $filename, but it might need to be decoded from UTF-8 also
13:09 nic grinnz: yeah, just noticed a min ago that what I'd typed was nonsense :(
13:09 nic thanks for the pointer tho
13:12 jberger The first time nic mentioned it, it did have slurp
13:12 nic yeah, I'm juggling two separate methods and managed to mangle them together on the second time round :D
13:14 nic Does slurp effectively decode based on the OS's default encoding, or is it not decoding and assuming bringing in raw bytes?
13:15 jberger IIRC it is not decoded, just bytes
13:15 nic k
13:15 jberger Tbh that's all it could do
13:16 jberger I might want to slurp data rather than text
13:16 nic yes, makes sense
13:16 zivester joined #mojo
13:17 nic I'll need to throw a snowman into one of my docs and see what happens :)
13:18 hernan605 joined #mojo
13:18 Grinnz Canary::Snowman
13:19 jberger nic: just remember, you have to decode on application boundaries
13:19 jberger Mojo often does it for you, but as I've said slurp can't
13:20 sri https://github.com/kraih/mojo/pull/824#issuecomment-128688215
13:21 stephen joined #mojo
13:21 * Grinnz really should try validation someday so he has an opinion on such things
13:24 jberger Grinnz: same
13:24 jberger It's definitely my blind spot
13:25 sri you should be able to point out shitty code though
13:25 jberger Note that I grok the router (which took me a while since I was more interested in async than large apps)
13:26 jberger I don't think I even looked at the code, there were no tests so I said no thanks
13:27 batman sri: hey!
13:27 batman +1 on your comment on #824
13:30 batman can we close https://github.com/kraih/mojo/issues/822 ?
13:33 jberger batman: Agreed, my comment is a -1
13:33 jberger with yours and sri's
13:42 gryphon joined #mojo
13:47 dotandimet1 joined #mojo
13:47 genio jberger++  # http://blogs.perl.org/users/joel_berger/2014/07/non-blocking-mojolicious-apps-are-even-easier-now.html clears up some questions I had
13:51 hernan605 a/win 2
13:55 punter joined #mojo
14:05 njlg joined #mojo
14:14 jberger that blog post reminds me that 5.0 was about making things easier, which makes me say that 6.0 was probably about making things consistent (thinking about Mojo::DOM)
14:24 chenri joined #mojo
14:33 nic I have a layout in a file (usual place) and a template I've slurp'd
14:33 nic Is there any way to combine them?
14:34 nic $c->render(inline => slurp "$filepath", layout => 'special') does not do it; it ignores the layout
14:34 eitz joined #mojo
14:36 nic ah, think I've got it
14:36 nic $c->content(undef, slurp($filepath)); $c->render(template => 'layouts/special', layout => undef)
14:36 jdporter joined #mojo
14:37 jdporter aloha
14:37 nic 'lo
14:37 jdporter I'm really getting frustrated by render() always html-escaping
14:38 nic double-escaping?
14:38 jdporter any escaping. maybe double-escaping.
14:38 nic Is this a confusion tween "%=" and "%==" ?
14:38 jberger render doesn't html escape
14:38 jberger nic beat me to it
14:38 jdporter I thought I had it licked, yesterday, when I threw a b() around the input html text
14:39 jdporter but now it's doing it again
14:39 nic do you have a paste you can share?
14:40 jdporter ah, let me try %==
14:42 jdporter ok, that definitely helped. thanks, guys!
14:42 jberger np
14:59 jdporter gah. stuff is still getting html-escaped and/or url-escaped :-(
14:59 lluad joined #mojo
15:00 jdporter I have a situation where I'm doing      %= link_to $txt => $url
15:01 jdporter and the $txt is what needs to not be html-escaped.  If (when) I show it plain, I do   %== $txt
15:01 jdporter but I guess for the link_to I have to do something like     %= link_to <%== $txt> => $url
15:03 jdporter but that doesn't quite work either
15:03 njlg joined #mojo
15:09 jontaylor Just got yet another email in from a recruiter, about yet another place that wants to throw away all their infrastructure and replace it with a rails app, with go microservices feeding into an ember JS frontend…
15:10 disputin joined #mojo
15:10 mst what could possibly go wrong ...
15:11 jontaylor I just don’t get it, i’m not saying it wont work or anything, but it just screams to me of places blindly flowing trends and buzzwords
15:13 jdporter it looks like link_to doesn't easily support an expression for its first arg
15:13 jdporter Guess I could fall back to   %=t a ...
15:17 nic $c->content(undef, slurp($filepath))->render(template => 'layouts/special', layout => undef);
15:18 nic When I do that I need to remove all the 'meta' lines (% title 'Fabulous Notes';) otherwise they get rendered as html
15:18 nic Anyone know a way around that?
15:19 nic The template (slurp'd) is the only thing that knows things like title and some other stash values; not the controller, nor layout
15:22 mattastrophe joined #mojo
15:23 jdporter gah. can't do it with  %=t 'a' either...  It looks like EP really doesn't want to support this kind of thing.  Odd.  Seems pretty basic to me.
15:27 jdporter had to fall all the way back to crappy ol'      <a href="<%== $url %>"><%== $txt %></a>
15:28 nic jdporter: I've become a big fan of url_for and url_with for cases where $url belongs to this app
15:29 PryMar56 joined #mojo
15:36 jdporter ok, cool.   unf. in my case it doesn't. :-)
15:40 Grinnz_ jdporter: yeah, the link_to helper probably is for regular link text only
15:40 jberger Grinnz_: why would that be?
15:40 jberger use begin/end
15:41 Grinnz_ https://metacpan.org/pod/Mojolicious::Plugin::TagHelpers#link_to
15:41 Grinnz_ examples of begin/end there
15:42 * Grinnz_ doesn't use tag helpers
15:44 PopeFelix joined #mojo
15:46 ZoffixWork joined #mojo
15:46 genio is it ok to:  if ( $more_results_remaining ) { $delay->steps(\&some_sub); $self->ua->get($next_url, $self->headers(), $delay->begin(0)); }    and basically repeat that in some_sub  ?  Adding a new step until there are none left
15:50 genio https://gist.github.com/genio/9edc9172f00e76400330 for example
15:52 hernan605 have you tried ?
15:53 genio everything works as I thought, but I'm wanting to make sure I'm not doing it stupidly
15:53 hernan605 it works
15:54 hernan605 what do you want to do ?
15:54 * sri currently works with rails too :S
15:54 hernan605 ruby ?
15:58 batman jdporter: check this out https://ssl.thorsen.pm/paste/dadc275e2832
15:58 batman jdporter: if you need <%== %> then you're doing something wrong (in 99% of the cases)
16:01 nic In my case, "if you're touching a keyboard then you're doing something wrong (in 99% of the cases)"
16:06 jberger genio: if you are interested, see my URLQueue gist: https://gist.github.com/jberger/5153008
16:06 jberger it was at least one way to do this kind of thing
16:12 berov joined #mojo
16:12 arthas joined #mojo
16:12 mattastrophe joined #mojo
16:13 sri jdporter: helpers are not EP
16:17 meshl joined #mojo
16:26 hernan605 whats wrong here? https://gist.github.com/anonymous/f538e8a0abcf80fab582
16:27 hernan605 i tell print "mypage" and it prints "wrapper"
16:30 hernan605 and log shows it parsed 3 templates
16:30 hernan605 but i see content of the last only
16:30 hernan605 what have i done wrong ?
16:35 arthas joined #mojo
16:39 sri jdporter: and for teh record, escaping in tag helpers has been discussed a lot before, it's a big design problem nobody has found a solution for yet
16:42 Grinnz_ there isn't a good "right answer" - some people will expect it to be escaped, and some will expect it not to
16:43 good_news_everyon joined #mojo
16:43 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vOxDJ
16:43 good_news_everyon mojo/master 0bfc963 Sebastian Riedel: fix bug in Mojolicious::Validator::Validation where empty optional...
16:43 good_news_everyon left #mojo
16:44 hernan605 am i doing it wrong ?
16:45 sri Grinnz_: it's also a performance issue, since we now use Mojo::DOM::HTML for rendering
16:45 mattastrophe joined #mojo
16:45 sri and it has different needs, preventing Mojo::Util::xss_escape from being used liberally
16:48 sri btw. ideas for golfing this down welcome https://github.com/kraih/mojo/commit/0bfc9634152f50e13d33a2c1a1f521ef60565332#diff-ea8a39c17a3297cc4c5cc85000fae422R85
16:50 hernan605 better example https://gist.github.com/anonymous/300017ee80cf2496023b
16:50 * sri 's perl is already getting rusty :/
16:52 sri hernan605: you need http://mojolicio.us/perldoc/Mojolicious/Plugin/DefaultHelpers#content_with
16:53 hernan605 ahhhhhh
16:53 hernan605 thanks
16:53 sri you have to manually overwrite the current buffers
16:53 hernan605 but i really expected that to work
16:53 hernan605 ok
16:56 mst sri: possibly overly golfed but http://paste.scsys.co.uk/496864
16:57 sri :)
16:57 sopanshewale joined #mojo
16:57 sri maybe a little
16:57 mst I figured you could ungolf the bits you didn't like
16:57 mst the 'for' was probably gratuitous but amused me
16:59 jberger mst: I was going down the same path
17:00 jberger not the "for" but the rest of it
17:02 disputin joined #mojo
17:03 mst I thought getting @output and @input declared together was nice
17:04 good_news_everyon joined #mojo
17:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vOxdZ
17:04 good_news_everyon mojo/master 6a51c3e Sebastian Riedel: use a little less code
17:04 good_news_everyon left #mojo
17:04 sri best i can do
17:04 sri cost of the fix is 2 lines now
17:04 Ptolemarch joined #mojo
17:04 dod joined #mojo
17:07 jberger hmmm, that negates mine
17:14 disputin joined #mojo
17:15 upasana joined #mojo
17:17 upasana_ joined #mojo
17:24 dod joined #mojo
17:27 mattastrophe joined #mojo
17:32 sri and back to fighting with bundler
17:37 mattastrophe1 joined #mojo
17:37 Ptolemarch joined #mojo
17:42 eitz joined #mojo
17:51 jdporter Grinnz_, thank you.... Now show me how to do that using a variable (e.g. $linktext) ... *without* the linktext getting html-escaped.
17:52 jdporter sorry, I meant batman
17:53 jdporter sri, thank you for the note about prior discussion. Ah well.
18:14 sopanshewale joined #mojo
18:14 jontaylor joined #mojo
18:30 ZoffixWork joined #mojo
18:43 ZoffixWork tempire++ # Mojolicious::Plugin::JSONP
18:43 ZoffixWork nice and easy
18:45 njlg joined #mojo
18:53 jdporter can someone explain in a nutshell what the difference is between a template and a layout?  i.e. why would I prefer   % layout 'foo'   over % include 'foo' ?
18:53 jdporter s/why/when/
18:55 jdporter is there some kind of "magic" that happens in the former?
18:55 ZoffixWork jdporter, doesn't include simply includes a chunk of template, whilst layout allows you to wrap it around your current template?
18:55 jdporter oh... yeah....
18:56 tempire \o/
18:56 jdporter well, I mean, you can set 'content' in the template, and that can get used (inserted) into the layout...
18:56 jdporter but I think that happens with include'd templates too, no?
18:57 juikuen joined #mojo
18:57 ZoffixWork jdporter, I also believe you can change layout by setting the stash variable. I doubt that happens with includes
18:57 jdporter I guess the question is whether stash manipulation that happens in the template before doing an 'include' has any effect in the include'd code
18:59 jberger when you render, you pick the template name
18:59 jberger if you wanted to define one template that included other templates to form structure, you would have a harder time picking it in the render call
19:00 jberger imagine it as some kind of huffman coding
19:00 jdporter hrm... like perl ;-)
19:00 jberger in the simple case of a template with a layout (and no other inclusions) the important distinction is the template name not the layout name
19:02 jdporter omg. I can select the layout via args in the render() call. sweet.
19:02 jberger yes
19:02 jdporter I've been using template variants.  I'll try this. :-)  thx
19:02 jberger template variants are a different, but related, concept (full disclosure: one that I don't use)
19:07 jdporter ok, I think I've got a pretty good structure, then:  https://ssl.thorsen.pm/paste/89e15690491e
19:08 jdporter using variants, appropriately, to select a template; each of those uses a different layout.
19:20 jberger jdporter: having end tags without their respective begin tags in the same template is really gross
19:21 jberger it will cause heartache and invalid html
19:21 PopeFelix joined #mojo
19:21 ZoffixWork note: they're option and you can get rid of them completely
19:22 ZoffixWork *optional
19:24 jdporter good enough for gummint work ;-)
19:25 sri oh, i was not quite correct earlier, the tag helper escaping problem is not as broad as i made it sound
19:25 jberger see, the layout is intended to contain the repetitive stuff like the purely structural tags
19:25 ZoffixWork My opinion on it is you have too many bits and pieces. You'll be later running around with dozens of files for one page, trying to find what to edit.
19:25 sri it only affects attributes, actual text between tags could theoretically be handled with xss_escape
19:26 sri not that i expect anyone to really care :)
19:27 jberger sri: what does the spec say about attributes? should their content be escaped?
19:27 jberger it seems to me that they should be right?
19:27 sri of course they should
19:27 sri this is about handling b()
19:27 sri like Mojo::Util::xss_escape does
19:28 jberger oh I understand
19:30 sri Grinnz_: btw. there's a test for your case now https://github.com/kraih/mojo-pg/commit/2111f3ba867553ed680278e110f56a755523e749
19:31 sri i already did that for concurrent queries, must have forgotten to do the same for sequential
19:31 sri <3 postgres, stuff just works
19:31 Grinnz_ ahh, the first $sth is destroyed when the second sub ends?
19:32 Grinnz_ first results object rather
19:32 sri the new sth that was created because the old one was still busy took its place
19:32 chenri left #mojo
19:32 sri although, you might still be in trouble with other databases than postgres
19:33 sri DBD::Pg has this special property that all results are received right away
19:33 Grinnz_ sri: yeah, that's the problem ;) i'm going to see if it's a bug in DBD::SQLite though
19:33 Grinnz_ SQLite definitely does not do that
19:33 Grinnz_ neither does mysql iirc
19:33 mst mysql_use_result does, mysql_store_result doesn't
19:33 mst IIRC
19:33 mst Ctrl+F the DBD::mysql docs for those two
19:33 Grinnz_ right, i remember that vaguely
19:34 sri it seems a bit odd at first, but it makes DBD::Pg super safe with cached statement handles
19:38 sri guess there could be many timing issues lurking if your sth still needs to receive data
19:38 Grinnz_ yes, it's a bad case to be in... the problem in SQLite primarily, is that rollback and commit seem to do *nothing* if there is such a sth
19:38 Grinnz_ which is very bad
19:39 Grinnz_ i would expect an error or something... but i'm not getting one :/
19:40 sri anyone using the http/2 patch for nginx yet?
19:40 sri as expected, they went with http/2 on the front, and http/1.1 on the back
19:42 jdporter is there a way to make a template silently ignore a missing stash variable?  or do I have to drop into perl for that, i.e.   <%= stash('foo') // '' %>
19:43 sri hahaha... "drop into perl"
19:43 jdporter it's a mindrame ;-)
19:43 sri you never left perl!
19:43 jdporter er, mindframe
19:43 jdporter I know
19:43 ZoffixWork :)
19:44 ZoffixWork jdporter, what do you mean "ignore"? It already does.
19:46 jdporter er,...  if I have %= $foo   and there is no stash variable 'foo', I get an error
19:47 jdporter (or am I thinking of     % foo  ?)
19:47 sri % no strict 'vars';
19:47 jdporter that's a thought.  I'm so used to the straitjacket...
19:48 mst sri: does the template get re-compiled every request?
19:49 mst oh, of course it will at least somewhat, never mind
19:50 sri MOJO_TEMPLATE_DEBUG=1 perl -Mojo -E 'a({inline => "% no strict \"vars\";\n%= \$foo"})->start' get /
19:51 sri the resulting sub is stored in a cache
19:52 jdporter thanks muchly
19:55 meshl joined #mojo
20:00 jberger jdporter: there's nothing wrong with accessing the stash by function to fix that problem too, as you already mentioned
20:00 jberger I'd worry about turning off strict refs
20:00 sri the real problem with optional stash values is that they prevent proper caching
20:00 jberger now that the templates are all compiled into a single namespace, those are now global variables, and if you reuse them, they would leak across
20:01 sri so you should just avoid them, initialize with undef or so
20:02 sri also mentioned here http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Stash-data
20:02 Dave with defaults() right?
20:02 Dave at app creation time (in startup())?
20:02 Grinnz_ i like the [% DEFAULT %] tag in TT for this reason...
20:03 sri whatever works for you
20:03 Dave what would you recommend? :)
20:03 Grinnz_ well, maybe not this reason, it ignores missing vars anyway
20:03 sri i pass my stash values to ->render()
20:04 Dave ah I see. :) thank you
20:05 Dave Also, hey Grinnz_ you did a patch for bind_params right?
20:05 Dave for SQLite?
20:05 Grinnz_ hm?
20:05 jdporter yeah, I'm passing stash values via my render_to_string() call.  Is there a way to set defaults in this case?
20:05 Grinnz_ i updated Mojo::SQLite, i suppose a commit is technically a patch
20:06 Dave :) what's the best way to get sri to consider a patch like that for Mojo::Pg?
20:07 Grinnz_ a PR with tests and documentation, or asking him about it :P
20:07 jberger jdporter: http://mojolicio.us/perldoc/Mojolicious#defaults
20:07 Grinnz_ https://github.com/Grinnz/Mojo-SQLite/commit/edc04fa98abec0f5b8137e0303134d04e0a74458
20:08 Grinnz_ i am not sure how much of that is applicable to DBD::Pg
20:08 Dave I'm not sure I have enough experience with Mojo for the former
20:09 Grinnz_ but Mojo::Pg already has some parameter binding overrides for dealing with JSON values; it would be implemented along with that
20:09 Grinnz_ that code is not present in ::SQLite as obviously SQLite has no JSON
20:09 Dave the geometric types are teaching me how to write plpgsql :/
20:11 mattastrophe joined #mojo
20:12 sri i would reject the patch without a good reason
20:13 Dave reason =~ /use case/ ?
20:13 sri yes
20:13 Dave I'm trying to store geometric points using Mojo::Pg? :)
20:13 sri and the problem is?
20:13 Dave not that I'm important either
20:14 Dave I can't use bind_params to force the interpretation as a point
20:14 sri and type annotations don't work?
20:14 Dave You mean "::point"? I admit I'm rather new to postgres
20:14 sri yes
20:15 Dave I couldn't get that to work
20:15 Dave doesn't mean it doesn't work ;)
20:15 sri i'm using type annotations a lot for json and stuff
20:15 Dave so INSERT INTO (point, json) VALUES (?::point, ?::json) ?
20:15 Dave what does DBD::Pg expect as ?::point?
20:16 sri https://github.com/kraih/mojo-pg/blob/master/t/database.t#L128
20:16 sri without the annotation it would just be a string
20:16 sri i know nothing about geo functions
20:17 Grinnz_ that's output, isnt it? specifying the bind types in that patch is for input
20:17 Dave right, not sure whether ::point wants an anon array of 2 elements or two arguments
20:17 mst Dave: find something that psql will accept as 'foo'::point
20:17 Dave heh
20:17 mst Dave: whatever that foo is, there's your answer
20:18 mst in fact
20:18 mst you muppet (sorry, but seriously)
20:18 mst http://www.postgresql.org/docs/9.4/static/datatype-geometric.html
20:18 mst representation: (x,y)
20:18 Dave are you calling me a muppet? :)
20:18 mst SELECT '(0,1)'::point;
20:19 mst yes, because I've never used it, and just read the top of the datatype documentation and tried it and it works fine
20:19 Dave yah but the exact syntax...let me see if I can find this link
20:19 mst the exact syntax I've just given you, and the docs for it
20:19 Dave bind_params are wanted for INSERT ... try an INSERT :D
20:19 Dave um not the syntax ... unless I'm missing something
20:19 mst what?
20:20 Dave section 8.8 there only lists the types, I don't see syntax
20:20 mst representation!
20:20 mst in 8-20
20:20 mst matthewt=> CREATE TABLE tst (id SERIAL, mypoint POINT);
20:20 Dave oh that's what those are?
20:20 mst matthewt=> INSERT INTO tst (mypoint) VALUES ('(0,1)'::point);
20:20 mst yes.
20:20 mst works fine
20:20 Dave ah but where did the "::point" come from?
20:20 Dave where is that documented?
20:20 mst that's the cast to point that sri already told you about
20:21 sri yea, i just read mst's first sentence and was able to do point stuff in psql
20:21 Dave right :) I got that by implicaction
20:21 Dave er implication
20:21 Dave was looking for exactly where that was documented
20:21 nic joined #mojo
20:21 mst well then look rather than asking me to
20:21 Dave I did
20:21 Dave yesterday
20:21 mst I already googled 'postgres point datatype' and read the first result out loud to you
20:21 mst now you get to try
20:21 mst sri: as ever:
20:21 jberger IIUC he means the cast
20:21 mst my programming superpower: actually reading the documentation and the code and then thinking until I understand what they mean.
20:22 Dave I have that power too =P
20:22 mst not today, apparently
20:22 Dave first 5 links have no string "::point" in them
20:22 mst ...
20:22 mst ........
20:22 mst dude, c'mon
20:22 jberger C is to (point)X as PG is to X::point
20:22 Dave of course you do know google returns different results to different people :D
20:22 mst < Dave> what does DBD::Pg expect as ?::point?
20:23 mst I answered that question. you'd already been spoonfed ::point
20:23 cfedde http://www.postgresql.org/docs/current/static/datatype-geometric.html
20:23 Dave I know, by implication, what "::<foo>" does for most values of <foo>
20:23 sri ->query('select ?::point', '(1,2)')
20:24 Dave what I want is the page in the postgres documentation that says "when you put :: in a statement, here's what that means"
20:24 Grinnz_ SQLite on the other hand needs to be explicitly told when you're giving it a BLOB in certain cases apparently, so...
20:24 cfedde most of the time sqlite does not care what you give it. It has "typeless" storage.
20:24 sri i have no clue if DBD::Pg actually sends the right data type or if postgres just type casts it correctly, but it just works
20:24 mst postgres casts it
20:24 Grinnz_ yeah, and then it guesses wrong and boom
20:24 mst if you google 'postgresql type cast ::'
20:24 mst and click the link
20:25 mst you get http://www.postgresql.org/docs/9.4/static/sql-expressions.html
20:25 jberger http://www.postgresql.org/docs/9.5/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS
20:25 mst and then the 'type casts' section tells you this
20:25 sri type casting in postgres is really fancy
20:26 * jberger dislikes it when a site makes me look at the source to get a section hash link
20:26 jberger c'mon posgres!!
20:26 Grinnz_ ^
20:26 Grinnz_ metacpan spoiled me
20:26 mst Dave: so, have I taught you enough google 101 for the day now
20:26 mst or is there some other manual you'd like me to read out loud for a bedtime story? :P
20:26 Dave Yo mst ... chill man
20:26 * Grinnz_ hates googling for postgres and mysql docs because it always ends up with some random version
20:27 Dave I don't acknowledge your geek angst, thank you still for helping me :D
20:27 mst I am perfectly calm, but you were being passive aggressively entitled so I'm going to be sarcastic about it
20:27 Dave I actually wasn't...text man
20:27 Dave text != emotion
20:27 mst then don't tell me to chill, if you can't read emotion in text
20:27 jberger Grinnz_: at least there are links at the top of the doc to take you to the same page in the other versions
20:27 mst you're not even making sense :P
20:27 Grinnz_ jberger: yeah, mysql has the same on the side, they usually work
20:27 Dave probably because no one ever thinks I make sense :)
20:27 Dave don't worry about it
20:27 jberger ok ok I'm declaring that anyone who is not chilled should therefore do so
20:27 mst anyway. go RTFM and be happy.
20:28 * Grinnz_ turns up the A/C
20:28 Dave thanks jberger for that link, I could not find that yesterday
20:28 mst but be aware that, generally, telling people to chill is considered a dick move, and don't do it ever again
20:28 sri Grinnz_: i don't see any bind_params garbage compete with the simplicity of this ;p ->query('select ?::point', '(1,2)')
20:28 mst it usually just makes them more annoyed
20:28 Dave mst, when you are berating someone you don't know, expect any response :)
20:28 sri Grinnz_: of course if there's a good reason to have it anyway...
20:28 Grinnz_ sri: sure... postgres probably doesnt have a case like this https://metacpan.org/pod/DBD::SQLite#Blobs
20:28 * cfedde goes to get the popcorn.
20:29 mst Dave: I am trying to teach you more about IRC's social norms so people don't stop helping you.
20:29 mst you don't have to listen
20:29 * jberger hands cfedde the butter and salt
20:29 mst but we'll just leave you flailing next time if you don't
20:29 Dave I am most definitely not normal :)
20:29 mst so, y'know, your choice
20:29 Grinnz_ sri: its a problem of the "typeless" storage i think
20:29 sri Grinnz_: not that i'm aware
20:30 Dave there is at least one social normal for every channel on every irc server, not all of them are the same
20:30 mst well, welcome to the basics of irc.perl.org
20:30 Dave you are all human (at least that's my assumption), and every group of humans is different
20:30 Dave if you are alien, my apologies :)
20:31 cfedde you are a unique snow flake. Just like everyone else.
20:31 mst yep, and I run half the ircds for this wider group of humans, so I've got some idea; I'd suggest listening first, and maybe telling me I'm wrong in a couple years or so :D
20:31 sri content of the postgres docs is pretty amazing though
20:31 mst sri: notice the whole '\0 will confuse things' thing at Grinnz_' link
20:31 Dave I dont ever want to tell you you're wrong mst :)
20:33 Grinnz_ postgres docs are basically How To Document Your Database The Right Way
20:43 * sri still wonders if people actually use forms with elements sharing the same name like <input name=foo><input name=foo>
20:44 sri and then having people fill out an arbitrary number of them
20:45 sri that's what #824 was about
20:45 mst it's been a long time since I've seen it in the wild, even in the more pathological codebases I've worked with
20:45 Grinnz_ yeah.. i havent seen that much
20:45 sri i mean, browsers totally allow it, so i guess it's sensible to support it, but i've never seen it
20:48 sri oh actually, some government websites with those huge ass forms might be using it
20:49 sri like, here's 50 input elements for you to list the names of family members
20:49 mst sri: I must admit, I think if I was designing a form handler now I'd provide built in support for 'x.y' and 'x[]' for arrays, but not two 'x' fields
20:49 mst and just say "if you wanted to do that, use something else"
20:50 sri honestly, so far i've found that kinda stuff rather underwhelming
20:50 sri and it makes validation awkward
20:51 sri if you expand the structure before validation everything is complicated, if you expand the strucutre after you get in trouble with names like x[4]
20:52 mst honestly, I think my current POV is "if it's getting complicated, maybe I wanted an SPA"
20:52 sri at least i find it really tricky to design a validation system for arbitrarily deep nested data structures
20:53 sri (some folks would like it for json too... but i've just not found a good design yet)
20:54 mst structured validation is ridiculously annoying, yeah
20:55 Grinnz_ thats a job for schemas...
20:57 Ptolemarch joined #mojo
20:57 asm35 joined #mojo
20:58 mst schemas are good for debugging
20:59 mst structured validation that produces human friendly errors is ... interesting
20:59 Grinnz_ yeah...
20:59 Grinnz_ when you want to automate something like that is when i start thinking XML is not the worst idea
21:00 * jberger thinks about xsd files and pukes
21:02 jberger though a fair amount of my revulsion was trying to get $job[-2] to use a proper xsd parser, but NIH prevailed and they promised to write me one when they had time
21:02 jberger so we kept shipping whatever we had to the upstream service, who kept bitching and sending copies of the xsd
21:02 jberger preaction: ^^
21:03 mst ahahahahahahaha niiiiice
21:03 jberger its even worse when you consider that we were supposed to be the new interface to that old service
21:04 jberger and we weren't even sending validated xml to the service we were eventually supposed to replace
21:04 jberger sigh
21:05 jberger which reminds me, I know a few skilled programmers who are still at $job[-2] and might want out
21:05 jberger if you need a skilled programmer, let me know
21:05 jberger or preaction :-)
21:06 btyler_ insert wisecrack about amsterdam
21:06 Dave sri: case 3 is what I'd like to use bind_params for -- http://fpaste.org/252864/89815381/
21:07 Grinnz_ Dave: would DBD::Pg use that as an array instead of a string with the point type in bind_param?
21:07 Grinnz_ whatever type that would even be...
21:07 Dave I don't really know actually :)
21:07 Grinnz_ i only know regular SQL types :s
21:07 Dave It should
21:08 Grinnz_ i think it might have to be converted to string regardless
21:08 Dave sri will probably say that because case 0 works, he doesn't need to patch anything :)
21:08 Grinnz_ for JSON, query() actually does to_json on any json parameters, converting it to a string
21:09 Dave maybe instead I could do "create index foo on tbl using gist((doc -> point))" ... I don't know postgres that well
21:10 mst Dave: case three has double [] so isn't a point
21:10 mst Dave: I don't understand why you'd thank that would work
21:11 Grinnz_ mst: the middle [] gets dereffed when passing to query
21:11 mst oh, right, weird syntax
21:11 Dave omg mst made a mistake! :)
21:11 * Dave faints
21:11 Grinnz_ https://metacpan.org/pod/DBD::Pg#bind_param
21:11 Dave I kind of want to have these 2 element anon arrays as points, call me a perl guy
21:12 Grinnz_ it looks like postgres does have "types" for each of its specific types... but no indication that it would actually parse an point that way
21:12 mst Dave: hang on, have you checked to see if psql will accept array syntax for ::point ?
21:12 Grinnz_ something you should try :)
21:12 Grinnz_ a point*
21:12 Dave mst: run the program :D
21:12 mst Dave: the program doesn't answer the question I asked
21:12 Dave hm
21:12 Dave Grinnz_ not sure what you are saying
21:13 Grinnz_ Dave: no, if you use bind_param and set the type to PG_POINT, does it take an array
21:13 Grinnz_ or does it still need to be a string
21:13 Dave I believe case 4 does mst, I could be wrong
21:15 sri would be odd if it accepted an array for case 4
21:15 mst ERROR:  cannot cast type integer[] to point
21:15 mst so it doesn't accept arrays for it
21:15 mst so bind_params won't help, you still need to provide the text form
21:15 mst at which point ::point will still work
21:15 sri case 0 looks nice
21:15 Grinnz_ lol
21:16 mst SELECT '{1,2}'::integer[];
21:16 mst SELECT '{1,2}'::integer[]::point;
21:16 mst will reproduce at psql
21:16 mst Dave: and that's what I meant by checking if psql would accept it
21:16 Dave what is {,}?
21:16 Grinnz_ postgres array
21:16 Dave ah
21:16 mst Dave: that's postgres array syntax
21:16 mst which is that DBD::Pg is documented to turn that arrayref into
21:17 mst http://www.postgresql.org/docs/9.4/static/arrays.html
21:17 * mst , documentation lookup bot
21:17 Dave array types in a table? wow
21:17 Dave no I haven't read the docs front to back :)
21:17 Grinnz_ Dave: welcome to postgres ;)
21:17 sri read about jsonb too
21:17 mst when I asked if postgres accepted array syntax
21:17 Dave I read that part sri :)
21:18 mst I also pre-emptively found the docs by googling 'postgres array syntax'
21:18 sri basically arbitrary data structures in a table
21:18 mst you can play along at home with this game :)
21:18 sri in an efficient binary form
21:18 Dave mst...again...you do know google returns different search results for different people?
21:18 * mst forgets if hstore can contain arrays
21:18 mst Dave: yes. and if you try that exact search term and screenshot it not giving you the manual, I'll believe that's the problem
21:19 mst but since they're very rarely -that- different, the null hypothesis is that you didn't try
21:19 sri poor hstore, jsonb gets all the press
21:19 mst sri: WEB SCALE! ;)
21:19 Dave ok mst but you had to know postgres had arrays in the first place ;)
21:20 mst when I asked 'does psql accept array syntax', if that didn't make sense, you should've asked what it was
21:20 Dave I was afraid to anger you again
21:20 Dave once you tell someone "google for answers", there's no going back :D
21:21 mst that doesn't mean I can't suggest things to google for
21:21 Dave and I really dont want to cause you stress, even though I don't know you and you have been berating me on occasion
21:21 mst in fact, if you notice, I've been being careful to tell you what I googled for
21:21 mst to improve your odds in future
21:21 Dave yes, you are giving me needed contextual information which improves my google search chances
21:21 sri omg, arrays in postgres are THE SHIT
21:22 mst but basically if you're genuinely in the situation of "I didn't understand that sentence so I don't know what to google for", asking that is not going to annoy me
21:22 Dave and jsonb gets the press because it's like mongodb which is apparently the hottest thing since sliced bread to some people I've been dealing with
21:22 mst http://trout.me.uk/mongodb.jpg
21:22 sri <3 https://github.com/kraih/minion/blob/master/lib/Minion/Backend/Pg.pm#L190
21:22 mst sri: the intersection etc. operators are nice
21:23 sri just for '...foo = any(?)...', ['bar', 'baz', 'yada']
21:23 Grinnz_ sri: :'(
21:23 Dave whoa
21:23 Dave I miss all the fun tools :(
21:23 Grinnz_ arrays are the primary reason i hate using mysql
21:23 Grinnz_ not even json
21:24 Grinnz_ arrays make things so much easier
21:24 Dave yeah I'd need some examples to understand that, right now that's why I use json everywhere
21:24 Dave so I don't have to worry about some SQL database's interpretation
21:25 Grinnz_ Dave: basically, what sri said instead of: ... where foo in (?,?,?...)
21:25 Grinnz_ and the manual query building that goes along with doing that for an array of values
21:26 Dave I sort of see...intersection operators are nice on arrays in the general case
21:26 * sri wonders when postgres 9.5 will finally be released
21:27 Dave I finally figured out upsert! :D
21:27 Dave for 9.4
21:27 Dave but 9.5 had something else good too...forget what
21:27 jberger upset :-)
21:28 Dave ? lol
21:28 jberger upsert
21:28 jberger properly
21:28 sri skip locked, built in sharding, new json functions
21:28 Dave "upset database" ... sends a message to all database clients just to desync them
21:28 Dave ahh built in sharding
21:28 jberger https://wiki.postgresql.org/wiki/UPSERT
21:29 Grinnz_ "upset database" is basically every mysql database
21:29 mst Dave: search http://www.trout.me.uk/quotes.txt for 'QUERY'
21:29 Dave also, for normal developers...people should realize postgres is a bit difficult to learn
21:29 jberger Dave: there was an excellent talk that someone here might still have the link to about failure testing and it was basically exactly that
21:29 Dave mst: your fortunes file is exactly like mine O.o
21:30 Grinnz_ mst: you shoulda timestamped these :D
21:30 mst well it is the standard unix fortune format
21:30 Dave wow...I'm getting old...forgot that
21:30 Grinnz_ hah
21:30 mst Grinnz_: then they wouldn't fit in 80x24 and therefore be ineligible for feeding to a sigmonster
21:31 Grinnz_ yes, well
21:31 Grinnz_ we just need to invent metadata for .txt
21:31 Dave yeah you have to be careful with signatures that are too long, you'll piss off the anal and drunk :)
21:31 Dave I'll never forget when I got berated for using MH
21:31 mst Grinnz_: oh, I have that, it's in an svn repo
21:31 Dave because it wraps lines
21:31 Grinnz_ mst: heh
21:32 mst Dave: I used to frequent alt.sysadmin.recovery
21:32 mst I'm in cluefire.net a couple times as a result
21:33 jberger hahaha
21:33 jberger "My hate/hate relationship with XML is, predictably, on 'hate' at the moment."
21:33 Dave you dont want to know the newsgroups I used to frequent
21:37 jberger I could get a bumper sticker with this on it: "My other computer is your Windows machine."
21:37 Grinnz_ lol
21:37 Dave heh
21:37 Dave and then some NSA agent notices...
21:40 jberger don't be silly, I wouldn't use a Windows computer even if it was yours
21:40 Dave mst: SELECT '{1,2}'::integer[]::point  should work ... I haven't read the array docs completely but even better would be SELECT '{1,2}'::integer[2]::pointld be SELECT '{1,2}'::integer[]::point
21:40 Dave and when I say "should" I mean "in my opinion"
21:40 mst Dave: well, when I tried it at psql, it didn't
21:40 Grinnz_ well, we're not postgres devs :P
21:40 Dave yeah
21:40 Dave I know
21:40 Grinnz_ at least, most of us...
21:40 jberger crab: around?
21:41 mst oooh, I just had an idea
21:41 * Dave ducks
21:42 Dave if I assume the postgres devs are extremely ana...er meticulously hubretic...then they meant something by having '(1,2)'::point work but not '{1,2}'::point
21:42 mst SELECT ( '(' || array_to_string('{1,2}'::integer[], ',') || ')' )::point;
21:42 mst WORKS
21:42 Dave O.o
21:43 Grinnz_ hah
21:43 mst so VALUES (( '(' || array_to_string(?::integer[], ',') || ')' )::point)
21:43 mst should accept [1, 2]
21:43 Dave lol
21:43 Dave ok trying that :D
21:43 Grinnz_ yeah, that's ... a thing
21:43 mst oh, except, without the ::integer[] sorry
21:44 mst so VALUES (( '(' || array_to_string(?, ',') || ')' )::point)
21:44 mst the ::integer[] was because I was supplying '{1,2}'
21:46 Dave I cant get that to work
21:46 Dave could not determine polymorphic type because input has type "unknown"
21:46 mst maybe try putting the ::integer[] back?
21:46 Dave now it tells me array_to_string does not exist...are you on 9.5 or something?
21:46 jberger in practice you probably don't want integer unless those are going to be integer points
21:47 mst Dave: 9.1 on the box I test things like this on
21:47 mst (hence why I test on that one)
21:47 Dave what is the || operator .. conditional?
21:48 Grinnz_ concat i believe
21:48 mst concat
21:48 Dave ahh I see now
21:49 Dave ok your thing there works in pgsql, but not in ->query()
21:49 Dave of course it's not exactly the same in my query implementation either
21:49 mst yeah, you'll need to fiddle a bit I'm sure
21:49 mst and I was just curious if I could make it work at all
21:49 Grinnz_ Dave: perhaps quoting issue?
21:49 mst I'm really not convinced this is better than just formatting it to '(1,2)' with a subroutine on the perl side
21:50 Dave neither am I tbh
21:50 Dave it's fun tho :)
21:50 mst right.
21:50 Grinnz_ screwing around with complex queries in postgres => fun
21:50 Grinnz_ screwing around with complex queries in mysql => kill me now
21:50 Dave lol
21:51 Dave actually I am using case 0 in my "production" code
21:51 mst hand editing mysql binary logs to the sound of atari teenage riot => mst
21:51 Dave O.o
21:52 mst I was ops those days. I needed replication back up.
21:52 Grinnz_ luckily, the only time i had to touch binary logs was in sphinx search, when the solution could feasibly be "just turn off binary logging, it'll reindex itself eventually"
21:52 mst where would be the fun in that?
21:53 Dave I tried so hard to avoid SQL anything for years
21:53 Dave big client needed SQL help...so that went out the window
21:54 Dave also I was bitten real hard by BerkeleyDB ... ouch
21:54 sri point(?,?) not good enough?
21:55 Dave it is
21:55 Dave extreme hubretic meticulousness caused me to search for other ideas, and sometimes point(?,?) doesn't work
21:56 Dave was having trouble with "select thing from table where loc = point(?,?)"
22:06 good_news_everyon joined #mojo
22:06 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vOhAi
22:06 good_news_everyon mojo/master 523ed7a Sebastian Riedel: input and output might not be the same (closes #825)
22:06 good_news_everyon left #mojo
22:22 d4rkie joined #mojo
22:25 d4rkie joined #mojo
22:36 Zoffix_ joined #mojo
22:39 d4rkie joined #mojo
22:46 * sri considers reverting the validation changes again https://github.com/kraih/mojo/issues/826
22:46 sri if this is where we are heading, it might be better to stick with the original behavior
22:47 sri tag helpers already can't handle multiple input elements with the same name
22:54 good_news_everyon joined #mojo
22:54 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vOjOl
22:54 good_news_everyon mojo/master 97f6f44 Sebastian Riedel: stick with the original validation behavior for now
22:54 good_news_everyon left #mojo
22:57 sri https://github.com/kraih/mojo/issues/826#issuecomment-128853331
23:25 bjoernfan joined #mojo
23:34 bpmedley joined #mojo
23:45 jberger joined #mojo
23:55 PopeFelix joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary