Commit 42ccbef8 authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

metadata: do not cache absent metadata

It can have annoying consequences before a first-time insertion.
parent 9659267cde67
......@@ -1074,6 +1074,15 @@ def test_serie_deletion(engine, tsh):
seriecount, csetcount, csetseriecount = assert_structures(engine, tsh)
assert tsh.metadata(engine, 'deleteme') == {
'tzaware': False,
'index_type': 'datetime64[ns]',
'value_type': 'float64',
'index_dtype': '<M8[ns]',
'index_names': [],
'value_dtype': '<f8'
}
with engine.begin() as cn:
tsh.delete(cn, 'deleteme')
......@@ -1087,8 +1096,24 @@ def test_serie_deletion(engine, tsh):
assert csetcount - csetcount2 == 2
assert csetseriecount - csetseriecount2 == 2
assert seriecount - seriecount2 == 1
assert tsh.metadata(engine, 'deleteme') is None
tsh.insert(engine, ts, 'deleteme', 'Celeste')
ts = pd.Series(
[1, 2, 3],
index=pd.date_range(start=utcdt(2018, 1, 1),
freq='D', periods=3)
)
with engine.begin() as cn:
tsh.insert(cn, ts, 'deleteme', 'Celeste')
assert tsh.metadata(engine, 'deleteme') == {
'tzaware': True,
'index_type': 'datetime64[ns, UTC]',
'value_type': 'float64',
'index_dtype': '|M8[ns]',
'index_names': [],
'value_dtype': '<f8'
}
def test_strip(engine, tsh):
......
......@@ -139,7 +139,8 @@ class TimeSerie(SeriesServices):
reg.c.seriename == seriename
)
meta = cn.execute(sql).scalar()
self.metadatacache[seriename] = meta
if meta is not None:
self.metadatacache[seriename] = meta
return meta
@tx
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment