Skip to content

Commit b9beaeb

Browse files
andyfelleraviau
authored andcommitted
Fixed code and updated tests for issue 320 (influxdata#321)
Thanks @afelle1 !
1 parent 3322fde commit b9beaeb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

influxdb/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def create_retention_policy(self, name, duration, replication,
502502
:type default: bool
503503
"""
504504
query_string = \
505-
"CREATE RETENTION POLICY %s ON %s " \
505+
"CREATE RETENTION POLICY \"%s\" ON \"%s\" " \
506506
"DURATION %s REPLICATION %s" % \
507507
(name, database or self._database, duration, replication)
508508

@@ -537,7 +537,7 @@ def alter_retention_policy(self, name, database=None,
537537
should be set. Otherwise the operation will fail.
538538
"""
539539
query_string = (
540-
"ALTER RETENTION POLICY {0} ON {1}"
540+
"ALTER RETENTION POLICY \"{0}\" ON \"{1}\""
541541
).format(name, database or self._database)
542542
if duration:
543543
query_string += " DURATION {0}".format(duration)
@@ -558,7 +558,7 @@ def drop_retention_policy(self, name, database=None):
558558
:type database: str
559559
"""
560560
query_string = (
561-
"DROP RETENTION POLICY {0} ON {1}"
561+
"DROP RETENTION POLICY \"{0}\" ON \"{1}\""
562562
).format(name, database or self._database)
563563
self.query(query_string)
564564

@@ -583,7 +583,7 @@ def get_list_retention_policies(self, database=None):
583583
u'replicaN': 1}]
584584
"""
585585
rsp = self.query(
586-
"SHOW RETENTION POLICIES ON %s" % (database or self._database)
586+
"SHOW RETENTION POLICIES ON \"%s\"" % (database or self._database)
587587
)
588588
return list(rsp.get_points())
589589

influxdb/tests/client_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ def test_create_retention_policy_default(self):
571571

572572
self.assertEqual(
573573
m.last_request.qs['q'][0],
574-
'create retention policy somename on '
575-
'db duration 1d replication 4 default'
574+
'create retention policy "somename" on '
575+
'"db" duration 1d replication 4 default'
576576
)
577577

578578
def test_create_retention_policy(self):
@@ -590,8 +590,8 @@ def test_create_retention_policy(self):
590590

591591
self.assertEqual(
592592
m.last_request.qs['q'][0],
593-
'create retention policy somename on '
594-
'db duration 1d replication 4'
593+
'create retention policy "somename" on '
594+
'"db" duration 1d replication 4'
595595
)
596596

597597
def test_alter_retention_policy(self):
@@ -608,22 +608,22 @@ def test_alter_retention_policy(self):
608608
duration='4d')
609609
self.assertEqual(
610610
m.last_request.qs['q'][0],
611-
'alter retention policy somename on db duration 4d'
611+
'alter retention policy "somename" on "db" duration 4d'
612612
)
613613
# Test alter replication
614614
self.cli.alter_retention_policy('somename', 'db',
615615
replication=4)
616616
self.assertEqual(
617617
m.last_request.qs['q'][0],
618-
'alter retention policy somename on db replication 4'
618+
'alter retention policy "somename" on "db" replication 4'
619619
)
620620

621621
# Test alter default
622622
self.cli.alter_retention_policy('somename', 'db',
623623
default=True)
624624
self.assertEqual(
625625
m.last_request.qs['q'][0],
626-
'alter retention policy somename on db default'
626+
'alter retention policy "somename" on "db" default'
627627
)
628628

629629
@raises(Exception)
@@ -644,7 +644,7 @@ def test_drop_retention_policy(self):
644644
self.cli.drop_retention_policy('somename', 'db')
645645
self.assertEqual(
646646
m.last_request.qs['q'][0],
647-
'drop retention policy somename on db'
647+
'drop retention policy "somename" on "db"'
648648
)
649649

650650
@raises(Exception)

0 commit comments

Comments
 (0)