Open dhirajgite opened 3 years ago
Thanks for raising the issue, @dhirajgite. I've tried reproducing the issue on my side, but it does not seem to show what you see. When I insert 2021-02-23T00:00:00
, I get back the same value when I read it from storage. May I ask what timezone you're in and what is set on your computer? May I also ask where you did the database interactions - client drivers or console? It's possible that the value you inserted and retrieved are correct, but when displayed onto screen, it's converted to your local time.
@haikalpribadi Thanks for the response
My timezone is India Standard Time UTC+5:30
for interactions with the database, I am using Python Client
I've set the time on my computer to India Standard Time, and tested inserting and reading a date through the Grakn Console, which goes through client-java, protocol, server, and back, and the issue does not show up, @dhirajgite.
haikalpribadi:graknlabs/grakn % ./dist/grakn-core-all-mac/grakn console
Welcome to Grakn Console. You are now in Grakn Wonderland!
Copyright (C) 2021 Grakn Labs
> database list
dNo databases are present on the server.
> database create grakn
Database 'grakn' created
> transaction grakn schema write
grakn::schema::write> define date sub attribute, value datetime;
Concepts have been defined
grakn::schema::write> commit
Transaction changes committed
> transaction grakn data write
grakn::data::write> insert $x 2021-02-23T00:00:00 isa date;
{ $x 2021-02-23T00:00 isa date; }
answers: 1, duration: 138 ms
grakn::data::write> match $x isa date;
{ $x 2021-02-23T00:00 isa date; }
answers: 1, duration: 111 ms
Can you recreate a small piece of code and push it to a public repo, and link it here, @dhirajgite? So I can get a complete reproducible scenario to debug the problem?
Please find an output I receive when using grakn console
Welcome to Grakn Console. You are now in Grakn Wonderland!
Copyright (C) 2021 Grakn Labs
> database create test
Database 'test' created
> transaction test schema write
test::schema::write> define
data sub entity,
owns date;
date sub attribute, value datetime;
Concepts have been defined
test::schema::write> commit
Transaction changes committed
> transaction test data write
test::data::write> insert $data isa data, has date 2021-03-01T00:00:00;
{ $data ←[34miid←[0m 0x966e80017fffffffffffffff ←[34misa←[0m ←[35mdata←[0m; }
answers: 1, duration: 72 ms
test::data::write> commit
Transaction changes committed
> transaction test data read
test::data::read> match
$data isa data,
has date $x;
get $x;
{ $x 2021-03-01T00:00 ←[34misa←[0m ←[35mdate←[0m; }
answers: 1, duration: 40 ms
test::data::read>
But When I use python client to query the same database I get the following output
class GraphDatabase(object):
def __init__(self, keyspace = "test"):
self.keyspace = keyspace
def _execute_entity_query(self, query, entity_type):
with GraknClient.core() as client:
with client.session(self.keyspace, SessionType.DATA) as session:
with session.transaction(TransactionType.READ) as tx:
print("Executing Graql Query: " + query)
result_iter = tx.query().match(query)
entities = []
for concept in result_iter:
ent = {}
entity = concept.map().get(entity_type)
for i in entity.as_remote(tx).get_has():
ent[i.as_remote(tx).get_type()._label] = i._value
entities.append(ent)
return entities
q = '''
match
$data isa data,
has date $x;
get $data;
'''
a = GraphDatabase()
b = a._execute_entity_query(q, "data")
print(b[0]['date'])
Outputs Following Results
Executing Graql Query:
match
$data isa data,
has date $x;
get $data;
2021-03-01 05:30:00
Thanks for sharing the code, @dhirajgite . @alexjpwalker will look into this issue soon.
Description
I have added a DateTime data in grakn as follow $a isa entity, has date 2021-02-23T00:00:00
but when I query the database it returns the date as 2021-02-23 05:30:00
it should be like this 2021-02-23 00:00:00
when added time as 2021-02-23T07:00:00 it returns 2021-02-23 12:30:00
Environment
Expected Output
2021-02-23 00:00:00
2021-02-23 07:00:00
Actual Output
2021-02-23 05:30:00
2021-02-23 12:30:00