Define and implement a way to set right column types when auto-generating the database
See original GitHub issueI’m submitting a
- [x ] feature request.
Current Behaviour:
All database columns are set to db.String
as Hydra do not require specifying the type of variable for a filed
Expected Behaviour:
Database columns should be created with dbString
, db.Integer
or db.Float
according to types defined in the ApiDoc or Ontology via properties like "@type": " "xsd:decimal"
as discussed in https://github.com/HTTP-APIs/creditrisk-poc/issues/6
I can work on this but I need support from @sameshl
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Chapter 4, Optimizing Schema and Data Types
It's a chapter on MySQL database design—it's about what is different when ... If you create a table with an aliased data type...
Read more >How do I specify that a property should generate a TEXT ...
DataAnnotations ) will work to create an ntext type column. ... and Code-First will generate the maximum sized data type that the database...
Read more >How to Select the Right Data Types
Data types define what kind and range of data can be stored in a given field (or column). Consider a sales table with...
Read more >Auto Generating Migrations — Alembic 1.9.1 documentation
Change of column type. This will occur if you set the EnvironmentContext.configure.compare_type parameter to True . The default implementation will reliably ...
Read more >Mapping Custom Data Types (CDTs) to Pre-defined ...
The CDT defines the data structure within Appian and how it maps to the ... Create. To create a new CDT based off...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
Right now, hydrus assumes that every property is either a string literal or a URI pointing to a resource. In both cases, they are stored as strings in the database. So for example if we have a property for
temperature
that is supposed to have a number, hydrus doesn’t check if the value sent to it is a number or not. It will store a URI if we send a URI in that field.When creating the tables in the database, we are not checking the
@type
field for a given supported property defined in the API documentation. We can implement this check when the database is being created or when the request/response is being processed. We say that we add support for the core RDF datatypes in hydrus. Whenever a supported property is a literal, it can be defined in the API documentation with one of these four types: “xsd:string”, “xsd:boolean”, “xsd:decimal”, “xsd:integer”.So suppose a property is defined as:
We cast the property as integer. Similarly for the other 3 datatypes.
In case the datatype is a custom type, it will be defined in the API documentation as :
In this case, the property is assumed to have instances of a resource of some existing ontology, and the field would then store only URIs pointing to instances of the resource, which may or may not be in the API. We do not need to derference the
@type
, because hydrus already assumes it to be an instance of some other resource.Something similar is implemented here already: https://github.com/HTTP-APIs/hydrus/blob/34c909e26e58bf2aee279391c7560d8536ff9f91/hydrus/data/db_models.py#L94
Where the @type is checked to be a resource from the same API doc to add foreign key relations. We just need to add checks below for “xsd:string”, “xsd:boolean”, “xsd:decimal”, “xsd:integer”. All other cases would be treated as URIs in the database to be stored as strings.
You can ping me on slack if you need any help.
There are major cons: