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

rename: have it as a method on the series handler

parent 2fc407bc0e9e
......@@ -8,7 +8,7 @@ import numpy as np
import pandas as pd
from tshistory.snapshot import Snapshot
from tshistory.util import rename_series, threadpool
from tshistory.util import threadpool
from tshistory.tsio import TimeSerie
from tshistory.testutil import (
assert_df,
......@@ -1454,10 +1454,8 @@ def test_rename(engine, tsh):
tsh.insert(engine, serie, 'bar', 'Babar')
tsh.insert(engine, serie, 'quux', 'Babar')
rename_series(engine, {
'foo': 'new-foo',
'bar': 'new-bar'
})
tsh.rename(engine, 'foo', 'new-foo')
tsh.rename(engine, 'bar', 'new-bar')
tsh._resetcaches()
......
......@@ -345,6 +345,17 @@ class TimeSerie(SeriesServices):
sql = sql.where(cset.c.insertion_date >= revdate)
return cn.execute(sql).scalar()
@tx
def rename(self, cn, oldname, newname):
reg = self.schema.registry
sql = reg.update().where(
reg.c.seriename == oldname
).values(
seriename=newname
)
cn.execute(sql)
self._resetcaches()
@tx
def delete(self, cn, seriename):
if not self.exists(cn, seriename):
......
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