Fork me on GitHub

I'm not familiar with that form of DATETIME but we regularly do this sort of thing DATE_SUB( NOW(), INTERVAL ? DAY ) and that works just fine (MySQL) @martinklepsch


might be a sqlite thing but yeah, fair point to look for a datetime helper that takes a number as input


it because jdbc's syntax using '?' isn't a kind of blind search an replace, the '?' token is only valid in certain places, and it isn't valid in the middle of a string literal


Ah, I didn't notice it was in a string in the first piece of code -- no, that definitely won't work. The example I gave isn't using a string. Good 👀 there @hiredman!


hey guys, need some help here I’m doing a CRUDish application and I have the follow relations

Session 1--------* Orders 1-------* Gateway-Transactions (gonna call transactions only )
just a simple usecase to exemplify the relations the system A creates a session with our service (payment system) and will register one sale POST /sessions/1/sale we are going to create one entry into Orders , another one into Transactions ( braintree/paypal/stripe whatever ) and the result , on success, we are going to register one movement ( CREDIT ). easy enough isn’t ? my problem is how to manage relationships using clojure. I’m using hugsql + defrecords to map my tables I would love, without N+1, fetch for instance, all movements with the transactions associated with them


I’m doing some joins into my Movement domain to fetch all data related with movements and transactions. but I need to map to the proper defrecord (Transaction) for instance


( missing some ORM … maybe too newbie , need to improve that )


It's just data. A joined query will be a sequence of hash maps.


You can transform it in memory to whatever shape you would prefer.


(ORMs are evil 🙂 )


yeah @seancorfield , (need to get that into my brain ) the shape (defrecord ) make my life easy to map to tables. so my problem is that the Movement namespace will require the Transaction namespace to shape the result


I’m coupling both 😞


(ns movement)
 (defn find-all-with-transactions-by-session [session-id] 


what I’m doing is:

(defn find-all-with-transactions-by-session [session-id] 
     (map create-movement-transaction (SQL QUERY WITH JOIN RETURN ALL DATA))


something like that and I’m felling dirty , really dirty ( like OO into functional )


Do you really need to separate these things out into separate namespaces? These aren't classes. If movements and transactions are related and you can't have one without the other, why have separate namespaces?


Also, why use records here rather than plain ol' maps?


hello @seancorfield! I'm using to query my database and everything is just fine... but... now I'm facing an issue because I need to extract the column types of the first row for a given query... it works just fine if the columns for that first row all have values, because it is a map, so, doing (type a-column-value) works. But when a column is null on database, a-column-value is also null (`nil`) and I can't get the type


so I think that if I could get the ResultsetMetadata I could get the type of that column.


But I can't figure out how to do that.


Sounds like you want the metadata for the table really, not for the query?

seancorfield22:10:25 -- that's a rough example that gets metadata for all tables... I'd have to look at the docs for .getTables in the Java SQL API docs for how to get just the one table you want...


(and part of me wonders why you need the types of the columns? @gleisonsilva)


> (and part of me wonders why you need the types of the columns?) because I need to generate a Avro schema for dumping the results of those queries as Avro files


Oh, OK. Well, using the metdata from the tables themselves is going to be a better approach anyway I think.