Skip to content

Commit 0827a3e

Browse files
committed
Update .gitignore and add parameters to Database.create_collection
1 parent 7ff6f2d commit 0827a3e

File tree

5 files changed

+147
-26
lines changed

5 files changed

+147
-26
lines changed

.gitignore

Lines changed: 110 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,110 @@
1-
*.pyc
2-
*.pyo
3-
*.idea
4-
*.egg-info
5-
*build/
6-
*dist/
7-
*htmlcov/
8-
*.coverage
9-
.cache/
10-
tests/__pycache__/
11-
*.DS_Store
12-
venv
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
# MacOS
107+
.DS_Store
108+
109+
# PyCharm
110+
.idea/

arango/aql.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ def execute(self,
230230
:type intermediate_commit_size: int
231231
:param satellite_sync_wait: Number of seconds in which the server must
232232
synchronize the satellite collections involved in the query. When
233-
the threshold is reached, the query is stopped. This parameter is
234-
for enterprise version of ArangoDB only.
233+
the threshold is reached, the query is stopped. Applies only to
234+
enterprise version of ArangoDB.
235235
:type satellite_sync_wait: int | float
236236
:param read_collections: Names of collections read during query
237-
execution. This parameter is required for transactions only.
237+
execution. Required for :doc:`transactions <transaction>`.
238238
:type read_collections: [str | unicode]
239239
:param write_collections: Names of collections written to during query
240-
execution. This parameter is required for transactions only.
240+
execution. Required for :doc:`transactions <transaction>`.
241241
:type write_collections: [str | unicode]
242242
:return: Result cursor.
243243
:rtype: arango.cursor.Cursor

arango/database.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,10 @@ def create_collection(self,
808808
shard_fields=None,
809809
shard_count=None,
810810
index_bucket_count=None,
811-
replication_factor=None):
811+
replication_factor=None,
812+
shard_like=None,
813+
sync_replication=None,
814+
enforce_replication_factor=None):
812815
"""Create a new collection.
813816
814817
:param name: Collection name.
@@ -863,6 +866,19 @@ def create_collection(self,
863866
every write to the master is copied to all slaves before operation
864867
is reported successful).
865868
:type replication_factor: int
869+
:param shard_like: Name of prototype collection whose sharding
870+
specifics are imitated. Prototype collections cannot be dropped
871+
before imitating collections. Applies to enterprise version of
872+
ArangoDB only.
873+
:type shard_like: str | unicode
874+
:param sync_replication: If set to True, server reports success only
875+
when collection is created in all replicas. You can set this to
876+
False for faster server response, and if full replication is not a
877+
concern.
878+
:type sync_replication: bool
879+
:param enforce_replication_factor: Check if there are enough replicas
880+
available at creation time, or halt the operation.
881+
:type enforce_replication_factor: bool
866882
:return: Standard collection API wrapper.
867883
:rtype: arango.collection.StandardCollection
868884
:raise arango.exceptions.CollectionCreateError: If create fails.
@@ -879,14 +895,9 @@ def create_collection(self,
879895
'doCompact': compact,
880896
'isSystem': system,
881897
'isVolatile': volatile,
882-
'keyOptions': key_options
898+
'keyOptions': key_options,
899+
'type': 3 if edge else 2
883900
}
884-
885-
if edge:
886-
data['type'] = 3
887-
else:
888-
data['type'] = 2
889-
890901
if journal_size is not None:
891902
data['journalSize'] = journal_size
892903
if shard_count is not None:
@@ -897,10 +908,19 @@ def create_collection(self,
897908
data['indexBuckets'] = index_bucket_count
898909
if replication_factor is not None:
899910
data['replicationFactor'] = replication_factor
911+
if shard_like is not None:
912+
data['distributeShardsLike'] = shard_like
913+
914+
params = {}
915+
if sync_replication is not None:
916+
params['waitForSyncReplication'] = sync_replication
917+
if enforce_replication_factor is not None:
918+
params['enforceReplicationFactor'] = enforce_replication_factor
900919

901920
request = Request(
902921
method='post',
903922
endpoint='/_api/collection',
923+
params=params,
904924
data=data
905925
)
906926

arango/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '4.0.1'
1+
__version__ = '4.1.0'

tests/test_collection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ def test_collection_management(db, bad_db):
151151
shard_count=2,
152152
shard_fields=['test_attr'],
153153
index_bucket_count=10,
154-
replication_factor=1
154+
replication_factor=1,
155+
shard_like='',
156+
sync_replication=False,
157+
enforce_replication_factor=False
155158
)
156159
assert db.has_collection(col_name) is True
157160

0 commit comments

Comments
 (0)