10000 Something wrong with JSON Schema `multipleOf` · Issue #21889 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Something wrong with JSON Schema multipleOf #21889

@Williamclouf

Description

@Williamclouf

My Environment

ArangoDB Version: 3.12.5
Deployment Strategy: Docker Compose
Operating System: Linux
Used Package: Docker image

Steps to reproduce

  1. Create a collection and setting a rule with "multipleOf" = 0.01
"rule": {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "amount": {
      "type": "number",
      "multipleOf": 0.01,
    },
  },
  "required": [
    "amount",
  ],
  "uniqueItems": true
}

or you can get Schema online

  1. Try insert data {"amount": 1.25} and {"amount": 111.25}:
from arango import ArangoClient
client = ArangoClient(hosts="http://127.0.0.1:8529")
db = client.db(db_name, username="root", password="")
accounts_collection = db.collection("accounts")
try:
    aa = 1.25
    res = accounts_collection.insert({"amount": aa,})
    print(aa, 
62FA
res)
except Exception as e:
    print(aa, e.__class__)

try:
    aa = 111.25
    res = accounts_collection.insert({"amount": aa,})
    print(aa, res)
except Exception as e:
    print(aa, e.__class__)

Result shows:

1.25 {'_id': 'accounts/609256', '_key': '609256', '_rev': '_kDjmgwG---'}
111.25 <class 'arango.exceptions.DocumentInsertError'>

I dont know if i misunderstood multipleOf, so i used online validation tool: https://www.jsonschemavalidator.net/s/hGc8KQ2F
which create a same JSON Schema and {"amount": 111.25} passed it.
I would be grateful if someone could help me figure it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0