Npgsql.Tests.ReaderOldSchemaTests.IsReadOnlyMetadataSupport C# (CSharp) Method

IsReadOnlyMetadataSupport() private method

private IsReadOnlyMetadataSupport ( ) : void
return void
        public void IsReadOnlyMetadataSupport()
        {
            using (var conn = OpenConnection())
            {
                conn.ExecuteNonQuery("CREATE TEMP TABLE data (id SERIAL PRIMARY KEY, int2 SMALLINT)");
                conn.ExecuteNonQuery("CREATE OR REPLACE TEMPORARY VIEW DataView (id, int2) AS SELECT id, int2 + int2 AS int2 FROM data");

                var command = new NpgsqlCommand("SELECT * FROM DataView", conn);

                using (var dr = command.ExecuteReader())
                {
                    var metadata = dr.GetSchemaTable();

                    foreach (DataRow r in metadata.Rows)
                    {
                        switch ((string)r["ColumnName"])
                        {
                        case "field_pk":
                            if (conn.PostgreSqlVersion < new Version("9.4"))
                            {
                                // 9.3 and earlier: IsUpdatable = False
                                Assert.IsTrue((bool)r["IsReadonly"], "field_pk");
                            }
                            else
                            {
                                // 9.4: IsUpdatable = True
                                Assert.IsFalse((bool)r["IsReadonly"], "field_pk");
                            }
                            break;
                        case "field_int2":
                            Assert.IsTrue((bool)r["IsReadonly"]);
                            break;
                        default:
                            break;
                        }
                    }
                }
            }
        }