-
Notifications
You must be signed in to change notification settings - Fork 12
/
sql_options.cljc
98 lines (80 loc) · 5.01 KB
/
sql_options.cljc
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
(ns com.fulcrologic.rad.database-adapters.sql-options
"Options supported by the SQL adapter")
(def table
"Attribute option. The name of the database table. Use on `ao/identity? true` attributes.
Defaults to the snake_case namespace name of the attribute."
:com.fulcrologic.rad.database-adapters.sql/table)
(def column-name
"Attribute option. The string name to use for the SQL column name. Defaults to
the snake_case name of the attribute."
:com.fulcrologic.rad.database-adapters.sql/column-name)
(def max-length
"Attribute option. The max length for attributes that are internally represented by strings. This
includes keywords, symbols, password, enumerations, and raw strings. This is ONLY used when this adapter
generates schema for it. Only used by the auto-generation. Defaults to 2k for strings, and roughly
200 characters for most other types."
:com.fulcrologic.rad.database-adapters.sql/max-length)
(def ^:deprecated sql->form-value "DEPRECATED. See sql->model-value."
:com.fulcrologic.rad.database-adapters.sql/sql->form-value)
(def ^:deprecated form->sql-value "DEPRECATED. See model->sql-value."
:com.fulcrologic.rad.database-adapters.sql/form->sql-value)
(def model->sql-value
"Attribute option. A `(fn [clj-value] sql-value)`. When defined, the
writes via the plugin's form save this function will call this to convert the model value into
something acceptable to the low-level JDBC call (see `next.jdbc.sql/execute!`).
WARNING: The keyword name of this option does not match this option name.
is :com.fulcrologic.rad.database-adapters.sql/form->sql-value."
:com.fulcrologic.rad.database-adapters.sql/form->sql-value)
(def sql->model-value
"Attribute option. A `(fn [sql-value] clojure-type)`. If defined, then this
is called when reading raw results from the database, and can be used to convert
the database value into the correct clojure data.
WARNING: The keyword name of this option does not match this option name.
is :com.fulcrologic.rad.database-adapters.sql/sql->form-value."
:com.fulcrologic.rad.database-adapters.sql/sql->form-value)
(def connection-pools
"Env key. This is the key under which your database connection(s) will appear
in your Pathom resolvers when you use the pathom-plugin (see that docstring).
This is actually a value that you generate, since when you install the pathom
plugin you must provide it with a database mapping function. This key is
where that database map is placed in the env."
:com.fulcrologic.rad.database-adapters.sql/connection-pools)
(def databases
"Config file key. Defines the databases used by the application in the config files and
the resulting config object.
The value of this option is a map from a developer-selected name (e.g. a shard or instance
name) to a specification for a database/schema. The *keys* of the database are *not*
schema names (from attributes), they are meant to allow you to create more than one
instance of a database (potentially with the same schema) where some of your users
might be on one, and others on another.
The values in each database config can include any keys you want, but there are some
predefined ones used by the built-in adapter:
* `:flyway/migrate?` - Indicate that you'd like to use Flyway to run migrations.
* `:flyway/migrations` - A vector of Flyway migration locations. See their docs.
* `:hikaricp/config` - A map that will be converted to properties to pass to a Hikari connection pool.
* `:sql/auto-create-missing?` - When true, the adapter will try to generate schema for
defined but missing attributes. NOT recommended for production use.
* `:sql/schema` - The RAD schema (you define) that this database should use. Any attribute
with a declared `ao/schema` that matches this should appear in the schema of this database.
For example:
```
:com.fulcrologic.rad.database-adapters.sql/databases
{:main {:flyway/migrate? true
:flyway/migrations [\"classpath:config/sql_migrations\"]
:hikaricp/config {\"dataSourceClassName\" \"org.postgresql.ds.PGSimpleDataSource\"
\"dataSource.serverName\" \"localhost\"
\"dataSource.user\" \"grp\"
\"dataSource.databaseName\" \"grp\"}
:sql/auto-create-missing? false
:sql/schema :production}}
```
"
:com.fulcrologic.rad.database-adapters.sql/databases)
(def delete-referent?
"Attribute option. Only has meaning for :ref types (both cardinalities). When an
existing reference is changed to point to a new thing, if this option is true then the thing that is no longer
referred to will be deleted. This allows for the basic simulation of Datomic's
isComponent flag. This is different than SQL CASCADE, because in this case nothing
has been deleted. The reference on which this option lives is just being changed
to point to a different thing."
:com.fulcrologic.rad.database-adapters.sql/delete-referent?)