Elffuss BraidHub

kikocis/java-driver public

Merge pull request #487 from datastax/java953

Fix MaterializedViewMetadata when base table name is case sensitive (…
Changeset44c762a33a2ed722eecdb799928508f61f05ab7af185496d63a15b9ad1d284f0
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2015-10-19 15:40 +02:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2015-10-19 15:40 +02:00
Parents2ce86b39619b, 044b7f20f16b

Browse the files at this changeset

4 files changed

modified changelog/README.md +1 −0
@@ -16,6 +16,7 @@
1616 - [improvement] Warn if a custom codec collides with an existing one (JAVA-934)
1717 - [improvement] Allow typed getters/setters to target any CQL type (JAVA-940)
1818 - [bug] Fix Cluster.connect with a case-sensitive keyspace (JAVA-950)
19+- [bug] Fix MaterializedViewMetadata when base table name is case sensitive (JAVA-953)
1920
2021
2122 ### 3.0.0-alpha3
modified driver-core/src/main/java/com/datastax/driver/core/MaterializedViewMetadata.java +1 −1
@@ -60,7 +60,7 @@
6060
6161 String name = row.getString("view_name");
6262 String tableName = row.getString("base_table_name");
63- TableMetadata baseTable = keyspace.getTable(tableName);
63+ TableMetadata baseTable = keyspace.tables.get(tableName);
6464 if(baseTable == null) {
6565 logger.trace(String.format("Cannot find base table %s for materialized view %s.%s: "
6666 + "Cluster.getMetadata().getKeyspace(\"%s\").getView(\"%s\") will return null",
modified driver-core/src/test/java/com/datastax/driver/core/MaterializedViewMetadataTest.java +7 −7
@@ -94,16 +94,16 @@
9494 public void should_create_view_metadata_with_quoted_identifiers() {
9595 // given
9696 String createTable = String.format(
97- "CREATE TABLE %s.t1 ("
97+ "CREATE TABLE %s.\"T1\" ("
9898 + "\"theKey\" int, "
9999 + "\"the;Clustering\" int, "
100100 + "\"the Value\" int, "
101101 + "PRIMARY KEY (\"theKey\", \"the;Clustering\"))",
102102 keyspace);
103103 String createMV = String.format(
104- "CREATE MATERIALIZED VIEW %s.mv1 AS "
104+ "CREATE MATERIALIZED VIEW %s.\"Mv1\" AS "
105105 + "SELECT \"theKey\", \"the;Clustering\", \"the Value\" "
106- + "FROM %s.t1 "
106+ + "FROM %s.\"T1\" "
107107 + "WHERE \"theKey\" IS NOT NULL AND \"the;Clustering\" IS NOT NULL AND \"the Value\" IS NOT NULL "
108108 + "PRIMARY KEY (\"theKey\", \"the;Clustering\")",
109109 keyspace, keyspace);
@@ -111,13 +111,13 @@
111111 session.execute(createTable);
112112 session.execute(createMV);
113113 // then
114- TableMetadata table = cluster.getMetadata().getKeyspace(keyspace).getTable("t1");
115- MaterializedViewMetadata mv = cluster.getMetadata().getKeyspace(keyspace).getMaterializedView("mv1");
116- assertThat(table).isNotNull().hasName("t1").hasMaterializedView(mv).hasNumberOfColumns(3);
114+ TableMetadata table = cluster.getMetadata().getKeyspace(keyspace).getTable("\"T1\"");
115+ MaterializedViewMetadata mv = cluster.getMetadata().getKeyspace(keyspace).getMaterializedView("\"Mv1\"");
116+ assertThat(table).isNotNull().hasName("T1").hasMaterializedView(mv).hasNumberOfColumns(3);
117117 assertThat(table.getColumns().get(0)).isNotNull().hasName("theKey").isPartitionKey().hasType(cint());
118118 assertThat(table.getColumns().get(1)).isNotNull().hasName("the;Clustering").isClusteringColumn().hasType(cint());
119119 assertThat(table.getColumns().get(2)).isNotNull().hasName("the Value").isRegularColumn().hasType(cint());
120- assertThat(mv).isNotNull().hasName("mv1").hasBaseTable(table).hasNumberOfColumns(3);
120+ assertThat(mv).isNotNull().hasName("Mv1").hasBaseTable(table).hasNumberOfColumns(3);
121121 assertThat(mv.getColumns().get(0)).isNotNull().hasName("theKey").isPartitionKey().hasType(cint());
122122 assertThat(mv.getColumns().get(1)).isNotNull().hasName("the;Clustering").isClusteringColumn().hasType(cint());
123123 assertThat(mv.getColumns().get(2)).isNotNull().hasName("the Value").isRegularColumn().hasType(cint());
modified driver-core/src/test/java/com/datastax/driver/core/TableMetadataAssert.java +1 −1
@@ -77,7 +77,7 @@
7777 }
7878
7979 public TableMetadataAssert hasMaterializedView(MaterializedViewMetadata expected) {
80- assertThat(actual.getView(expected.getName())).isNotNull().isEqualTo(expected);
80+ assertThat(actual.getView(Metadata.quote(expected.getName()))).isNotNull().isEqualTo(expected);
8181 return this;
8282 }
8383