GithubHelp home page GithubHelp logo

saeschdivara / arangopy Goto Github PK

View Code? Open in Web Editor NEW
33.0 8.0 5.0 348 KB

Python driver Framework to access https://github.com/triAGENS/ArangoDB

License: MIT License

Python 99.25% Shell 0.75%
arangodb python

arangopy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arangopy's Issues

Model.objects.get_or_create() return model instance and Boolean for new or existing

When calling Model.objects.get_or_create(foo='bar'), it would be nice to get the instance as first element of the return and a Boolean as the second.
The Boolean simply says False, when the Item already exists and True when it has to be created. Or the other way around, whatever is more intuitive.

def something():
  item, item_new = Model.objects.get_or_create(foo='bar')
  if item_new:
    item.save()

Model.objects.get_or_create() can not query and save a ForeignKey related document

When calling Model.objects.get_or_create(other_model=reference_model) and saving the Model by Model.save() a "not JSON serializable" error will be raised.

reference_model = ReferenceModel.objects.get(foo='bar')
model, model_new = Model.objects.get_or_create(reference=reference_model)
if model_new:
    model.save()

raises this error

TypeError: <app.models.ReferenceModel object at 0x106b05b50> is not JSON serializable

Model.objects.get_or_create() set the parameters of the new item

When calling Model.objects.get_or_create(foo='bar') I get an empty object back. After a save, the query parameters were set as null in the database, when I do not apply them again.
Possibility to set the parameters used for the query by default, without setting them again before saving the object?

Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app.models import Model
>>> model_instance = Model.objects.get_or_create(name='test001')
>>> print model_instance.name
None
>>> model_instance.save()
>>> print model_instance.name
None

Filter on TextField and CharField returns no documents

When filtering a document on a TextField or CharField returns no object. In this case i json.dumps a JSON and save this in a TextField.
When i look at the document in the AdminInterface of arangodb, the string seems to be encapsulated. Doing a filter-query on that string seems to return no result.

>>> from app.models import Model, ReferenceModel
>>> r = ReferenceModel.objects.all()[:1]
>>> r = r[0]
>>> r
<app.models.ReferenceModel object at 0x10f7ee5d0>
>>> m = Model()
>>> m.reference_model = r
>>> m.save()
>>> m.property = '[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]'
>>> m.save()
>>> m.property
[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]
>>> list = Model.objects.filter(property='[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]')
>>> list
<arangodb.orm.models.CollectionQueryset object at 0x10f808f50>
>>> list[0]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/orm/models.py", line 39, in __getitem__
    self._generate_cache()
  File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/orm/models.py", line 325, in _generate_cache
    result = self._query.execute()
  File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/query/advanced.py", line 234, in execute
    result = Query.execute_raw(query_string=query_data)
  File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/query/advanced.py", line 83, in execute_raw
    raise err
HttpClientError: Client Error 400: http://localhost:8083/_db/test_db1/_api/cursor

When I check the arangadb document properties i see that the saved string has been encapsulated.

[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]

bidirectional edge

In arangodb there is no option to create bidirectional edge. However two directed edges can be created. When using CollectionModel and ForeignKeyField we specify one column (_from or _to) to be foreign key to another single table only. So there is no way to create a bidirectional edge.

AQL Escaping

Please give a method or automatic escape the input values for the aql string

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.