Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odata v4 #77

Draft
wants to merge 36 commits into
base: wip-odata-v4
Choose a base branch
from
Draft

Odata v4 #77

wants to merge 36 commits into from

Commits on Nov 7, 2019

  1. Splits python representation of metadata and its parser

    The current implementation of python representation of metadata and metadata parser was tightly interconnected. Support for other versions of OData was not possible as in each version elements are added, removed or modified. Therefore, we decided to split metadata representation and its parser. With this approach, we can easily define supported elements and its parsing functions in a single class. This "configuration" class is stateless and has to be a child of ODATAVersion.
    
    Additional changes including updating directory structure and refactoring old code to accommodate for incoming ODATA V4 support.
    
    New module model:
    - builder -> MetadataBuilder was moved here to make code easier to read
    elements -> All EDM elements were moved here, to make python representation of elements version independent. All parsable elements have to inherit from "from_etree_mixin".
    
    - from_etree_callbacks -> All  from_etree static methods were moved into separated function. This is a naive approach as its premise is that all from_etree implementations will be reusable in version V4.
    
    - types_traits -> "types traits" were moved here to make code cleaner and easier to read.
    
    Module V2:
    - __init__ -> includes OData2 definition.
    
    - service -> function-wise nothing has been changed.
    
    "Main" module:
    - config -> class Config was moved here to make it version and model-independent. In case we will ever need a config class also for service. Also ODataVersion class lives here.
    
    - policies -> All policies were moved here as well as ParserError enum. Again to make policies version and model-independent.
    
    Tests were only updated to incorporate new API.
    mamiksik committed Nov 7, 2019
    Configuration menu
    Copy the full SHA
    3515a36 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2019

  1. Add separate type repository for each child of ODATAVersion

    In every release of OData new types are not only added and removed but
    also there are changes to the existing types notably in formatting.
    Thus, there is a need to have separate type repository for each OData
    version.
    
    Let's see an example of Edm.Double JSON format:
    OData V2: 3.141d
    OData V4: 3.141
    
    https://www.odata.org/documentation/odata-version-2-0/overview/#AbstractTypeSystem
    
    http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html
    mamiksik committed Nov 8, 2019
    Configuration menu
    Copy the full SHA
    c93cccd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2b0f622 View commit details
    Browse the repository at this point in the history
  3. Add implementation of schema for OData V4

    - Enum types is working
    - Complex type is working(including BaseType)
    - Entity type needs editing
    mamiksik committed Nov 8, 2019
    Configuration menu
    Copy the full SHA
    f2b854b View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2019

  1. Change the implementation of dynamic dispatch function from_etree

    MixinFromEtree was removed in favour of the function called
    build_element. This is because A) Not always etree was passed, so the
    name was misleading. B) The purpose of splitting model and parse
    function was to be able to reuse certain part of code among different
    version of ODATA, but that was not fully possible with the previous
    solution as you had to import given element's class(which could be
    different for each version).  Thus, you would have to introduce
    unnecessary inherency to solve this.
    
    New function build_element takes two positional arguments and rest is
    kwargs. First one is element's class or element's class name as a string.
    Element class is preferred as it makes refactoring easier and does not
    introduce magical strings to the code. The name string option is here
    to solve those cases when you cant import needed element class due to
    version differences. Second argument is config.
    Martin Miksik authored and mamiksik committed Nov 13, 2019
    Configuration menu
    Copy the full SHA
    aa68a10 View commit details
    Browse the repository at this point in the history
  2. Fix test_types_repository_separation test

    Previous test was faulty as it relied on being call before any other
    test initiated ODataV2.Types.
    mamiksik committed Nov 13, 2019
    Configuration menu
    Copy the full SHA
    03e866b View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2019

  1. Add support for NavigationTypeProperty in V4

    Functions and elements removed/replaced in V4 corresponding with
    NavigationTypeProperty were moved to v2 module.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    27302d2 View commit details
    Browse the repository at this point in the history
  2. Remove enum type from OData V2

    Despite implementing enum for V2 the first mention of enum in
    specification is only in later versions of OData. Thus, it should not be
    possible to parse enum using V2 parser.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    c7f8f72 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5ab9113 View commit details
    Browse the repository at this point in the history
  4. Add support for TypeDefinition in OData V4

    TypeDefinitions are simply aliases for primitive types. They can be
    annotated. Thus, reimplementation of annotation for V4 is included in
    this commit.
    
    Children of ODataVersion have to specify which annotations are supported
    and how they should be processed. Annotation are parsed using function
    'build_annotation'. As annotation are always tied to specific element
    and there is no centralized repository of annotations this function must
    return void.
    
    http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part3-csdl/odata-v4.0-errata03-os-part3-csdl-complete.html#_Toc453752574
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    9c47514 View commit details
    Browse the repository at this point in the history
  5. Change implementation of struct type build functions

    They(EnumType, EntityType, ComplexType) now handle parsing of invalid
    metadata independently. Thus, you do not have to wrap build_element in
    try-except block. Build function either return valid type, null type or
    fails. (Last two options depend on which policy is set.)
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    21c944d View commit details
    Browse the repository at this point in the history
  6. Add V4 to pyodata cmd interface

    Also imports' paths were updated to correctly reflect project structure.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    92a12bc View commit details
    Browse the repository at this point in the history
  7. Fix import error in python 3.6

    In Python 3.7 importlib which resolves imports was updated. It allowed
    to use "import x.y as c" in __x__.py, but as we support python 3.6 as
    well we needed to optimize to work properly even with previous versions
    of importlib. Thus, the reason for this commit.
    
    All imports of files defined in the same folder as __module__.py are
    now in the form of "from .x import a,b,c". Also, since now all relevant
    classes for using pyodata e. g. elements, types are now directly
    imported in the appropriate module. User should always use API exposed
    directly from importing "pyodata.v2" or "pyodata.v4"
    
    Moreover, to remove cyclic imports:
    1) Adapter function for build_entity_set(Credit to Jakub Filak)
    was added as well as class.
    
    2) ODATAVersion was moved to separate file.
    
    3) Redundant function schema_from_xml which required importing
    pyodata.v2 was removed. Used MetadataBuilder(xml, Config(ODataV2))
    instead.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    37382de View commit details
    Browse the repository at this point in the history
  8. Fix parsing datetime containing timezone information for python 3.6

    Required method for parsing datetime 'fromisoformat' was added in
    python version 3.7, thus backport of that method was added to
    the requirements list.
    
    Also '%z' directive was updated in python 3.7 to support timezone
    information in the "+xx:xx" or "Z" format. Hence, changes were made to
    allow compatibility of these notations in python 3.6 and lower.
    
    https://docs.python.org/3/library/datetime.html
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    41d26fb View commit details
    Browse the repository at this point in the history
  9. Change default value of precision if non is provided in metadata

    According to ODATA V4 specification when precision is not provided
    it defaults to infinity. ODATA V2 specification does not provide any
    information regarding the default value and ODATA V3 specification
    is unclear. Thus, following the ODATA V4 specification for all versions
    seams as the best idea.
    
    https://www.odata.org/documentation/odata-version-3-0/common-schema-definition-language-csdl/#csdl5.3.4
    
    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/csprd06/odata-csdl-xml-v4.01-csprd06.html#sec_Precision
    
    https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/csprd06/odata-csdl-xml-v4.01-csprd06.html#sec_Scale
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    de69e21 View commit details
    Browse the repository at this point in the history
  10. Add untracked files to the .gitignore

    Folder .htmlcov is generated by the
    "make report-coverage-html"
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    25a782d View commit details
    Browse the repository at this point in the history
  11. Fix type hinting for ErrorPolicy's children

    Type hint Type[ErrorPolicy] was not resoling correctly for its children.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    474cd3a View commit details
    Browse the repository at this point in the history
  12. Add permissive parsing for TypeDefinition

    Before it was not possible to skip parsing of invalid
    TypeDefinition node.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    2d6ccaa View commit details
    Browse the repository at this point in the history
  13. Changes all manually raised exception to be child of PyODataException

    This is to better handle permissive parsing as otherwise we could be
    catching unwanted exceptions.
    
    Test were updated to expect different exceptions.
    mamiksik committed Dec 20, 2019
    Configuration menu
    Copy the full SHA
    961c950 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    9837b3a View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2020

  1. Configuration menu
    Copy the full SHA
    75100cb View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2020

  1. Configuration menu
    Copy the full SHA
    b6d1081 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2e0d451 View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2020

  1. Add type annotations to the majority of variables and functions in Se…

    …rvice V2
    
    Before developing the Service V4 I wanted to fully understand how V2 works, however without
    data types it was nearly impossible to grasp the meaning of the code. Hence, this commit.
    mamiksik committed Apr 17, 2020
    Configuration menu
    Copy the full SHA
    7fba358 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    06320bf View commit details
    Browse the repository at this point in the history
  3. More types!

    mamiksik committed Apr 17, 2020
    Configuration menu
    Copy the full SHA
    f160c93 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2020

  1. Configuration menu
    Copy the full SHA
    17f4834 View commit details
    Browse the repository at this point in the history
  2. More documentation

    mamiksik committed Apr 24, 2020
    Configuration menu
    Copy the full SHA
    1d0193d View commit details
    Browse the repository at this point in the history

Commits on May 1, 2020

  1. Configuration menu
    Copy the full SHA
    bdd010c View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2020

  1. Configuration menu
    Copy the full SHA
    29a71bf View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b3e033b View commit details
    Browse the repository at this point in the history

Commits on Jun 22, 2020

  1. Add optional dependency into extras_require is setup.py.

    It was already included in the file optional-requirements.txt but it was missing from setup.py, which cased inconsistency.
    mamiksik committed Jun 22, 2020
    Configuration menu
    Copy the full SHA
    9638dfe View commit details
    Browse the repository at this point in the history
  2. Add logging for policy ignore

    The error message should never be thrown away.
    mamiksik committed Jun 22, 2020
    Configuration menu
    Copy the full SHA
    005854c View commit details
    Browse the repository at this point in the history
  3. Fix formatting of policy.py

    mamiksik committed Jun 22, 2020
    Configuration menu
    Copy the full SHA
    9ef4cf5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fab1712 View commit details
    Browse the repository at this point in the history
  5. Add types to builder.py

    mamiksik committed Jun 22, 2020
    Configuration menu
    Copy the full SHA
    d9348cd View commit details
    Browse the repository at this point in the history