Fork me on GitHub
#datomic
<
2024-01-29
>
hifumi12305:01:37

Not sure where to report this, but it seems that MySQL 8.2 does not support the way Datomic creates users in bin/sql/mysql-user.sql. The fix was to execute something like

CREATE USER datomic@localhost IDENTIFIED BY 'datomic';

GRANT ALL ON datomic.* TO datomic@localhost;
This seems supported on older versions of MySQL, too.

👍 1
Stefan07:01:47

Hi all, I'm getting CVE's from one of Datomic's components: memcache-asg-java-client-1.1.0.36.jar. I posted an overview here: https://ask.datomic.com/index.php/966/multiple-cves-are-reported-on-datomic-peer-1-0-7075. I'm not getting any response there. Is there somebody over here who knows if this is a problem and how to fix it? Thanks!

1
👀 1
Stefan15:01:00

For those interested, my question has been answered on http://ask.datomic.com:

Stefan15:01:13

> Memcache-java-asg is a fork of com.aws/elasticache-java-cluster-client which is a fork of spymemcached. You should feel free to exclude our dependency here as needed. You would only use this jar if you were using elasticache and auto node discovery

jaret19:02:01

Hey @UGNFXV1FA I wanted to make sure you saw my last update. After further investigation we believe these are all false positives: https://ask.datomic.com/index.php/966/multiple-cves-are-reported-on-datomic-peer-1-0-7075

Stefan19:02:23

I hadn’t seen that, thanks for the heads up! These false positives can be annoying at times but overall I guess we’re better off using nvd-clojure!

👍 1
jaret19:02:16

I mean the good outcome here is we weren’t actually checking that jar as we thought. Now we are.

👍 2
Stefan08:02:33

Oh by the way: only excluding that jar in the datomic dependency gave me runtime errors about "class not found", so I ended up just suppressing the CVEs.

Aviv09:01:23

Hello, I’m managing a tree and aiming to track any modifications made to it. To achieve this, I’m utilizing the tx API, which enables me to query the tree with asOf and retrieve the tree differences using tx. Transactions cover not only the tree but also other data. What is the optimal approach to designate the transactions associated with the tree? (is there a tx metadata maybe?) Thanks! 🙏

silian21:01:43

Could you provide some code as example?

👍 1
Aviv09:01:19

Let’s say my schema has nodes, users and modifications:

(def schema [{:db/ident :node/id
              :db/valueType :db.type/string
              :db/cardinality :db.cardinality/one
              :db/unique :db.unique/identity}

             {:db/ident :node/val
              :db/valueType :db.type/string
              :db/cardinality :db.cardinality/one
              :db/unique :db.unique/identity}

             {:db/ident :node/children
              :db/valueType :db.type/ref
              :db/cardinality :db.cardinality/many}

             {:db/ident :user/id
              :db/valueType :db.type/string
              :db/cardinality :db.cardinality/one
              :db/unique :db.unique/identity}

             {:db/ident :user/name
              :db/valueType :db.type/string
              :db/cardinality :db.cardinality/one}

             {:db/ident :modification/id
              :db/valueType :db.type/string
              :db/cardinality :db.cardinality/one
              :db/unique :db.unique/identity}
             
             {:db/ident :modification/user-id
              :db/valueType :db.type/ref
              :db/cardinality :db.cardinality/one}])

(d/transact (get-connection) {:tx-data [{:node/id "1"
                                         :node/val "node 1"
                                         :node/children [{:node/id "2"
                                                          :node/val "node 2"}]}]})

(d/transact (get-connection) {:tx-data [{:user/id "1"
                                         :user/name "name"}]})
Let’s say i want to get all modifications made by some user, this means i need to link the transaction to user. I thought maybe the modification/id would be the tx-id? add metadata to the tx if possilbe (probably no longer need modification attribute)? Thanks 🙏

Aviv10:01:02

I think the main question is how to link a transaction to my own data, what is the best practice?

Aviv15:01:21

@U02U1T66REZ I have added another entity in my schema and inserted it in the same transaction that was made to the tree, which gave me the tx link between them

👍 1
duckie 1
Tobias Sjögren12:01:39

What is the mechanism for associating a set of enumerated values with an attribute as the only valid values ?

terjesb07:01:13

Datomic does not enforce this. For maintaining valid options, you could use convention/namespacing of enum entities, or perhaps add some metadata on the schema entities. For example, having an enum entity reference its schema attribute. An example of namespacing is in attribute_groups.clj in day-of-datomic. For constraining in transactions, look into Attribute Predicates and Entity Specs in the Schema docs. See e.g. entity_specs.clj in day-of-datomic. These could then use the mechanisms above to know the valid options and then reject tx for invalid options.

👍 1
cch114:01:25

+1 for entity and attribute specs for this sort of constraint. It's opt-in, but better than nothing.

Andrew Berisha14:01:53

This is a simple question, but is there a way to generate sample within a pull query?

Andrew Berisha14:01:19

Something like:

(d/q '[:find (pull ?e [:category/name {:category/items [:item/name]}])
          :where [?e :category/name]]
        db)
In the example above I want to do something like sample 10 to get a random list of items per category. Currently, I'm just left with applying sample after I make the request or using something like
(d/q '[:find [?category-name (sample 10 ?item-name)]
 :where [?e :category/name ?category-name]
        [?e :category/items ?i]
        [?i :item/name ?item-name]]
        db)
which does what I want, I'm just curious about applying that function within a pull syntax

cch118:01:21

Nothing easy comes to mind. Pull is really designed to work after the query has identified the entities and once you start pulling, the aggregate functions (like sample) are out of scope. There is an ability to limit the number of referenced entities that are returned -but to the best of my knowledge it's not equivalent to a true sample. See this:https://docs.datomic.com/cloud/query/query-pull.html#limit-option

🙏 1
Andrew Berisha21:01:10

So probably the best way to return their ids mapped to the values in this type of mapping would be using tuples:

[:find [?tup-category (sample 10 ?tup-item)]
     :where [?e :category/name ?category-name]
            [(tuple ?e ?category-name) ?tup-category]
            [?e :category/items ?i]
            [?i :item/name ?item-name]
            [(tuple ?i ?item-name) ?tup-item]]