Fork me on GitHub
#datomic
<
2015-07-23
>
Kira Sotnikov17:07:10

I’m trying to download datomic distro

Kira Sotnikov17:07:45

wget error: 20 redirections exceeded.

bostonaholic18:07:32

are schema alterations not supported for datomic:mem databases?

marshall18:07:28

@lowl4tency: you can increase the # of allowed redirects by including

marshall18:07:32

--max-redirect=number

robert-stuttaford18:07:58

bostonaholic: what happens when you try?

robert-stuttaford18:07:35

no mention of a restriction in the docs

bostonaholic18:07:51

datomic.impl.Exceptions$IllegalArgumentExceptionInfo: :db.error/not-an-entity Unable to resolve entity: :foo in datom [:foo :db/ident :bar]

robert-stuttaford18:07:14

mind sharing the code that produced that?

robert-stuttaford18:07:34

the + button on the slack text input has a snippet paste

bostonaholic18:07:45

{:db/id :foo
 :db/ident :bar}

bostonaholic18:07:55

that's my "alteration"

robert-stuttaford18:07:17

{:db/id [:db/ident :foo] :db/ident :bar}

Kira Sotnikov18:07:46

marshall: thank you, i’ve already get it through my laptop simple_smile

bostonaholic18:07:47

@robert-stuttaford: Unable to resolve entity: [:db/ident :foo] in datom [[:db/ident :foo] :db/ident :bar]

bostonaholic18:07:42

a little backstory, I'm trying to load the schema for tests. transacting the schema is happening through https://github.com/rkneufeld/conformity

robert-stuttaford18:07:43

what does (d/pull db [:db/ident :foo] ‘[*]) produce?

robert-stuttaford18:07:10

ah. altering schema has specific syntax. also, conformity will only ever load a given named norm once

bostonaholic18:07:37

yeah, I use the alter schema with conformity just fine for the production app

:app/v3 {:txes [[{:db/id :foo
           :db/ident :bar}]]}

robert-stuttaford18:07:27

ok. were i in your shoes, i’d first validate the db actually has :foo in it. does it? 😁

robert-stuttaford18:07:33

stranger things have happened to me

bostonaholic18:07:47

yeah, that's where I'm heading now

Ben Kamphaus18:07:42

@bostonaholic: schema alteration on mem should work — example

(ns datomic-manual-tests.mem-schema-alteration
  (:require [datomic.api :as d]))

(def db-uri "datomic:")
(d/create-database db-uri)
(def conn (d/connect db-uri))

(def schema [{:db/id (d/tempid :db.part/db)
              :db/ident :person/name
              :db/valueType :db.type/string
              :db/cardinality :db.cardinality/one
              :db.install/_attribute :db.part/db}])
@(d/transact conn schema)

(def pname-id
  (-> (d/db conn)
      (d/pull [:db/id] :person/name)
      :db/id))

(def alter-tx [{:db/id :person/name
                :db/ident :person/first-name
                :db.alter/_attribute :db.part/db}])
@(d/transact conn alter-tx)

(-> (d/pull (d/db conn) [:db/ident] pname=id)
    :db/ident)
; :person/first-name

robert-stuttaford18:07:28

you just don’t need to sync to wait for results like you do with durable storage

bostonaholic18:07:05

I wonder if it's because my alteration tx doesn't include :db.alter/_attribute :db.part/db

Ben Kamphaus18:07:56

Well, if you change e.g. cardinality, uniqueness, index you should get this specific error:

java.lang.IllegalArgumentException: :db.error/invalid-attribute Schema change must be followed by :db.install/attribute or :db.alter/attribute […]

bostonaholic18:07:19

yeah, I'm just renaming

Ben Kamphaus18:07:26

renaming shouldn’t require alter then, actually: http://docs.datomic.com/schema.html#renaming-an-identity

bostonaholic18:07:35

I wonder if this is because conformity isn't transacting each norm in the order I'm assuming it is

bostonaholic18:07:26

since it's a map of norm-name:transactions

bostonaholic18:07:32

so when it's trying to rename a datom :foo and conformity hasn't transacted the definition of :foo

Lambda/Sierra18:07:23

@bostonaholic: As I recall, Conformity uses declared dependencies of schema sections to determine order.

bostonaholic18:07:32

@stuartsierra: hmm, I can't find in the docs how I declare a dependency

Lambda/Sierra18:07:44

@bostonaholic: Yeah, neither can I. I must be thinking of something else.

Lambda/Sierra18:07:11

I guess it's transacting them in the order you give to ensure-conforms

bostonaholic18:07:49

I give ensure-conforms my map that looks like:

{:app/v1
 {:txes [[{...}

          {...}]]}

 :app/v2
 {:txes [[{...}]]}}

bostonaholic19:07:07

and since it's a map, comformity cannot guarantee that :app/v1 is transacted before :app/v2

bostonaholic19:07:21

thanks for you help everyone

arohner21:07:26

I’m trying to d/datoms :avet :foo/bar, where :foo/bar is an attr of type :db.type/ref. It’s failing with “:attribute-not-indexed”. I thought :db.type/ref was always indexed, and reverse indexed?

marshall21:07:36

ref types are indexed in VAET