<    April 2017    >
Su Mo Tu We Th Fr Sa  
                   1  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
30
00:37 AYGHOR joined
00:47 ta_ joined
01:40 cyclotron3k joined
01:42 <cyclotron3k> Anyone around to chat architecture?
01:52 <adam12> Sure
01:52 <adam12> Not that I'm an expert.
01:53 <cyclotron3k> I'm just thinking aloud here...
01:54 <cyclotron3k> I have a large web app (not rails) and part of that app includes a large amount of code that can create a database schema
01:55 <cyclotron3k> it basically turns an in-house dsl into a database schema
01:55 <cyclotron3k> I'm in the process of splitting that code out into a stand-alone gem
01:56 <cyclotron3k> The code currently expects a global variable, 'DB', to be set
01:57 <cyclotron3k> I'm wondering if I should convert the code to take the database connection as a parameter
02:03 <cyclotron3k> I'm also wondering if the gem should either generate the models on the fly, output models as scaffolding, or just let the user write their own models... if you see what I mean
02:10 <adam12> Hmm
02:11 <adam12> Well, starting in reverse - I'd personally prefer scaffolded models with option of overwriting
02:12 <adam12> DB is presumed, but you likely should be able to pass it in. Even if it defaults back to DB. Tell don't ask principle.
02:13 <cyclotron3k> Scaffolding would be good because it should load faster (I think?), but that's a lot of boiler plate code
02:15 <cyclotron3k> I was thinking, seeing as your passing in the entire schema, the gem would be able to generate all the models on the fly, and then if the user wanted to add any extra functionality they could extend the generated model
02:15 <cyclotron3k> *you're
02:15 <cyclotron3k> But processing the entire schema every time your app loads could really slow things down
02:20 <cyclotron3k> Gems relying on the presence of global variables - that's pretty uncommon right?
02:24 <adam12> Yes
02:24 <adam12> but I would say that Sequel might be the exception as DB is normally advocated to hold the database
02:24 <cyclotron3k> yeah
02:25 <adam12> I'd still make it changeable, but just assume that it would be DB by default
02:29 <cyclotron3k> Still thinking aloud: If my gem relies of the presence of a global var only, then the entire gem would be stateless and I wouldn't have to instantiate my gem; everything could be done with class methods.
02:29 <cyclotron3k> Are there any benefits or drawbacks to that?
02:31 <adam12> I guess it depends on the interface. I've been known to abuse the heck out of module_function but Rubyists expect to work with objects of some sort.
02:48 <cyclotron3k> cool, thanks
02:48 <cyclotron3k> I've got to go get my phone screen replaced now. brb
05:18 ian joined
05:19 <Guest53564> can anyone explain how to use sequel to connect to an ec2 instance with postgres?
05:34 <cyclotron3k> are you connecting from the same host or a different one?
05:36 <Guest53564> a different one
05:37 <Guest53564> ideally I want to run a script from a CI server that pulls data from an ec2 instance with postgres
05:41 <cyclotron3k> Sequel.postgres :database => 'your_db_name', :user => 'maybe_postgres', :host => 'id-123-12-13-412.ec2.amazon.com', :password => 'the password'
05:41 <cyclotron3k> Something like that
05:42 <cyclotron3k> You'll need to open port 5432
05:42 <cyclotron3k> And you'll probably want to restrict what can connect to that port
05:42 <cyclotron3k> Can you connect with pgAdmin III?
05:43 <Guest53564> I haven't tried with pgAdmin yet
05:44 <Guest53564> what do you mean by open port 5432?
05:44 <cyclotron3k> Postgres normally listens for connections on port 5432
05:44 <cyclotron3k> A standard EC2 instance will not allow anyone to connect on the port though
05:45 <Guest53564> I've changed the pg_hba.conf
05:46 <Guest53564> to temporarily add 0.0.0.0/0 host all
05:46 <cyclotron3k> Ok, that's half of the problem solved.
05:47 <cyclotron3k> Amazon won't be allowing connections on port 5432, so you'll need to go into your AWS console and modify the security group
05:47 <Guest53564> ahh ok
05:48 <cyclotron3k> Allow TCP connections on port 5432. but you'll probably want to restrict the IP range that's allowed to connect. You really don't want to allow the whole world to connect to your db
05:51 <Guest53564> Ok will do, trying now
06:08 <Guest53564> hmm I got a "no pg_hba.conf entry for host" error
06:09 <cyclotron3k> sounds like you're getting through to postgres now, but postgres is rejecting your connection
06:12 <cyclotron3k> difficult to say what the problem is without seeing your pg_hba.conf
06:13 <cyclotron3k> have you restarted postgres since you last modified the config?
06:14 <Guest53564> yea I have
06:18 <Guest53564> Oh I guess when I restarted the Postgres server
06:18 <Guest53564> it cleared my changes
06:25 <Guest53564> ok I think I got it from here, thank you for all the help cyclotron3k!
06:37 <cyclotron3k> no problem :)
08:47 arne__ joined
08:53 ta_ joined
08:56 gloscombe joined
10:09 ta_ joined
10:15 ta_ joined
11:00 ta_ joined
12:46 ben__ joined
12:51 <arne__> jeremyevans: ::Sequel.pg_jsonb_op(:custom_fields).get('Test').send(:json_op,Sequel::Postgres::JSONBaseOp::GET_PATH_TEXT,'{}')
12:52 <arne__> i can't get this behaviour anyhow else, am i right?
12:52 <arne__> (i want to use "test"::jsonb #>> {}
12:52 <arne__> maybe .get_text without parameters should yield this result
12:53 <arne__> since it is the only way ( as it seems ) to get "test"::jsonb => ::text, AFTER you selected it
12:53 <arne__> sure, there is ->> but still
13:10 ben__ joined
13:15 ben__ joined
13:26 ta_ joined
14:08 mwlang joined
14:09 <jeremyevans> arne__: Sequel.pg_jsonb_op("test").get_text([]) # assuming you want to call it with an empty array, using pg_array and pg_json_ops extensions
14:10 <arne__> i think i tried that
14:10 <arne__> and it is not the same as #>> '{}'
14:15 <jeremyevans> arne__: how is it different? ARRAY[]::text[] and '{}'::text[] are the same, right?
14:16 <arne__> *tests*
14:19 <arne__> Sequel::DatabaseError: PG::IndeterminateDatatype: ERROR: cannot determine type of empty array
14:19 <arne__> LINE 1: SELECT (('{"test":"test"}'::jsonb -> 'test') #>> ARRAY[])
14:19 <arne__> and if i cast the array to :"text[]" .get_text won't recognize it as array at all
14:27 <jeremyevans> arne__: DB.literal Sequel.pg_jsonb_op("test").get_text(Sequel.pg_array([], :text))
14:38 <arne__> ah i didn't now pg_array can take a type
14:39 <arne__> thanks
14:41 ta_ joined
14:41 tercenya joined
17:49 jaequery joined
18:26 Renich___ joined
19:51 kenaniah joined
20:08 <kenaniah> Hi all, quick question — anyone know how I can get CTI to filter associations properly in this example? https://gist.github.com/kenaniah/f54056c5b2e841820e36d038580eba36
20:10 <jeremyevans> kenaniah: Try using the master branch with the :alias=>:children option to the class_table_inheritance plugin
20:11 <jeremyevans> kenaniah: It wraps all the CTI subclass datasets in subqueries, and fixes a lot of issues like yours
20:11 <jeremyevans> kenaniah: note that it may require changes to your code if you are explicitly qualifying to subclass tables in your queries
20:14 <kenaniah> wow, that worked
20:15 <kenaniah> amazing work as usual, Jeremy
20:15 <jeremyevans> kenaniah: actually, :alias=>:parents would probably be better in your case, but the actual alias used doesn't matter much if you aren't using it explicitly
20:17 <kenaniah> jeremyevans: while you’re here, any notes on how I can explicitly remove duplicated columns on child tables from the dataset used without having to resort to rewriting all of the association handlers?
20:18 <kenaniah> My goal is essentially just to remove the child’s duplicate columns while still using Sequel’s automatically generated dataset otherwise
21:47 kenaniah joined