From fe28679e7bf826f1e058e76ff24fd49749ec0b9d Mon Sep 17 00:00:00 2001 From: Tyler Hobbs Date: Tue, 1 Jul 2014 12:05:54 -0500 Subject: [PATCH] Fix dclocal_read_repair_chance table metadata Fixes PYTHON-84 --- CHANGELOG.rst | 2 ++ cassandra/metadata.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b1f89816..2b986715 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -36,6 +36,8 @@ Bug Fixes (PYTHON-81) * Properly defunct connections after protocol errors * Avoid UnicodeDecodeError when query string is unicode (PYTHON-76) +* Correctly capture dclocal_read_repair_chance for tables and + use it when generating CREATE TABLE statements (PYTHON-84) 2.0.2 ===== diff --git a/cassandra/metadata.py b/cassandra/metadata.py index 76de53d7..9b15fc27 100644 --- a/cassandra/metadata.py +++ b/cassandra/metadata.py @@ -301,6 +301,16 @@ class Metadata(object): def _build_table_options(self, row): """ Setup the mostly-non-schema table options, like caching settings """ options = dict((o, row.get(o)) for o in TableMetadata.recognized_options if o in row) + + # the option name when creating tables is "dclocal_read_repair_chance", + # but the column name in system.schema_columnfamilies is + # "local_read_repair_chance". We'll store this as dclocal_read_repair_chance, + # since that's probably what users are expecting (and we need it for the + # CREATE TABLE statement anyway). + if "local_read_repair_chance" in options: + val = options.pop("local_read_repair_chance") + options["dc_local_read_repair_chance"] = val + return options def _build_column_metadata(self, table_metadata, row): @@ -662,7 +672,8 @@ class TableMetadata(object): recognized_options = ( "comment", "read_repair_chance", - "dclocal_read_repair_chance", + "dclocal_read_repair_chance", # kept to be safe, but see _build_table_options() + "local_read_repair_chance", "replicate_on_write", "gc_grace_seconds", "bloom_filter_fp_chance",