Giter Site home page Giter Site logo

Comments (4)

MGlauer avatar MGlauer commented on September 6, 2024

"fields": [null] is not something I would consider valid. But this is debatable.
Semantically this means "There is a field and this field is nothing" which is weird.

from omi.

christian-rli avatar christian-rli commented on September 6, 2024

Hmm, that makes sense. I tried to fill out a string that has no foreignKey, but preserving all keys of the metadata json structure. This is not possible however.

When "foreignKeys": [{"fields": [], ... AND
When "reference":{ "fields": null, ...} there is a TypeError ('NoneType' object is not iterable).

When "foreignKeys": [{"fields": [], ... AND
When "reference":{ "fields": [], ...} there is an Exception (Missing reference in foreign key).

With the option of an existing field in which there is nothing:
When "foreignKeys": [{"fields": [null], ... AND
When "reference":{ "fields": [null], ...} there is a key Error: None (which is just logical, I suppose)

With everything just null:
When "foreignKeys": [{"fields": null, ... AND
When "reference":{ "fields": null, ...} there is a TypeError: 'NoneType' object is not iterable (because a list is expected)

Now the way I found around this is to just leave foreignKeys as an empty list "foreignKeys": []. However this eliminates a few json keys from the oemetadata string. I think there is an added value to allowing to preserve those keys even with no foreign keys. The question is how big that value is.

I guess it makes logical sense to have an empty list when there are no foreignKeys. However this does not conform to our approach / our recommendation of just putting null wherever something does not apply. Although, I suppose helper tools could help users steer around this pitfall...

In your opinion @MGlauer , what would a key preserving empty foreignKeys section look like that omi should be able to parse? Or does the concept of an empty nested object not make sense at all?

from omi.

MGlauer avatar MGlauer commented on September 6, 2024

You are right, there is no solution to this problem - and this is intentional. If a list has length > 0 it means that there must be an object in this list. Therefore, if there is an object in the list of foreign keys, there is a foreign key and a foreign key has required fields - e.g. fields and a target table with columns. I am not sure what a foreign key without columns would be. So, yes, such a structure does not make sense

from omi.

christian-rli avatar christian-rli commented on September 6, 2024

OK, thanks for elaborating. I can follow that logic.

From this follows then that strings without a foreign key need to be an empty list like so "foreignKeys": []. Any helper tools should consider this and it should also probably be reflected in the helpful comments section at the bottom of the string. I'll add it to OpenEnergyPlatform/oemetadata#34

Closing this issue and adapting the original string that made me open this issue.

from omi.

Related Issues (20)

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.