Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-9951

thin php: Date data type cut nanos

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.7
    • thin client
    • None
    • Ignite 2.7 latest sources
      default cache configuration
      Python 3.7
      nodejs 10+
      PHP 7.2+
      Ubuntu 17

    Description

      When using PHP data types TIMESTAMP or DATE have problem with getting data with others clients, main reason that is nano seconds was cutted from php client side

      PHP code

      
      <?php
      require_once '/vendor/autoload.php';
      
      use Apache\Ignite\Client;
      use Apache\Ignite\ClientConfiguration;
      use Apache\Ignite\Data\Date;
      use Apache\Ignite\Type\ObjectType;
          
      $client = new Client();
      $ENDPOINT = '127.0.0.1:10800';
      $client->connect(new ClientConfiguration($ENDPOINT));
          $cache = $client->getOrCreateCache("PH_DATE")
                          ->setKeyType(ObjectType::INTEGER)
                          ->setValueType(ObjectType::DATE);
          $cache->put(1,Date::fromDateTime(DateTime::createFromFormat('Y-m-d H:i:s.u', '2018-10-19 18:31:13.029726')));
      
      

      JS output

      "2018-10-19T15:31:13.000Z"
      

      Py code

      from pyignite import Client
      from pyignite.datatypes import *
      client = Client()
      client.connect('127.0.0.1', 10800)
      cache = client.get_or_create_cache("PH_DATE")
      print(str(cache.get(1, key_hint=IntObject)))
      

      Py output

      2018-10-19 18:31:13
      

      When im using JS or Python for put looks like
      Py

      2018-10-19 18:31:13.029000
      

      JS

      "2018-10-19T15:31:13.029Z"
      

      Same story with Timestamp when
      PHP put

      
      <?php
      require_once '/vendor/autoload.php';
      
      use Apache\Ignite\Client;
      use Apache\Ignite\ClientConfiguration;
      use Apache\Ignite\Data\Timestamp;
      use Apache\Ignite\Type\ObjectType;
          
      $client = new Client();
      $ENDPOINT = '127.0.0.1:10800';
      $client->connect(new ClientConfiguration($ENDPOINT));
      try {
      
          $cache = $client->getOrCreateCache("PH_TIMESTAMP")->setKeyType(ObjectType::INTEGER)->setValueType(ObjectType::TIMESTAMP);
          $cache->put(1,(new Timestamp((DateTime::createFromFormat('Y-m-d H:i:s.u', '2018-10-19 18:31:13.029734'))->getTimestamp() * 1000, 29734)));
      
      } finally {
          $client->disconnect();
      }
      

      Py output

      (datetime.datetime(2018, 10, 19, 18, 31, 13), 29734)
      

      should look like

      (datetime.datetime(2018, 10, 19, 18, 31, 13, 29000), 29734)
      

      Or JS

      "2018-10-19T15:31:13.000Z"
      

      should look like

      "2018-10-19T15:31:13.029Z"
      

      Also wanna to admit that PHP Method Timestamp::fromDateTime(Data) didn't take nano seconds from date time (thats why in timestamp initialization i am doing what i do)

      Attachments

        Issue Links

          Activity

            People

              pavel.petroshenko Pavel Petroshenko
              spilschikov Stepan Pilschikov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: