HTTP-APIs / hydrus

REST server - Flask Hydra-powered for Semantic Web
https://pypi.org/project/hydrus/
MIT License
195 stars 130 forks source link

Added support for datatype for columns in database tables. #594

Closed farazkhanfk7 closed 3 years ago

farazkhanfk7 commented 3 years ago

Fixes #581

Checklist

Current behaviour

Database columns should be created with String, Integer or Float according to types defined in the ApiDoc.

New expected behaviour

hydrus will check for range of supported_properties. If the supported_property has a range ( specified datatype ) then column in database table will be created accordingly. For ex:

"range": "https://www.w3.org/TR/xmlschema-2/#integer"

Currently, I have added support for Integer and Float only. We can also add DateTime column after this. If a user won't pass range as an argument while creating HydraClassProp then the column will be treated as String in hydrus database. Example (Passed "xsd:integer" as range for two random HydraClassProp in apidoc): img

Also, I've made changes in gen_dummy_object function, so that it'll also check the type of column before creating it's dummy object. If the column type is integer or float, then a random integer is returned ( instead of a string).

Change logs

farazkhanfk7 commented 3 years ago

@Mec-iS I think checks are failing because Travis is using a different version of hydra-python-core which hasn't been released yet. The job throws error that says that HydraClassProp object doesn't have a kwargs attribute. The tests are passing on my local. Can u please confirm.

Mec-iS commented 3 years ago

ok. let's release the new hydra-python-core and update the requirements. please @farazkhanfk7 create an account at https://pypi.org/ and send me your username on Slack

sameshl commented 3 years ago

If the column type is integer or float, then a random integer is returned

@farazkhanfk7 If the column type is a float, shouldn't a float value be returned?

farazkhanfk7 commented 3 years ago

@sameshl Yes, a float should be returned. But if the column type is Float, an integer 20 will be treated as 20.0 in database. This is why I created a random integer for both types.