diff --git a/core/includes/schema.inc b/core/includes/schema.inc
index e599923..774d0e9 100644
--- a/core/includes/schema.inc
+++ b/core/includes/schema.inc
@@ -433,20 +433,8 @@ function drupal_write_record($table, &$record, $primary_keys = array()) {
 
     // Type cast to proper datatype, except when the value is NULL and the
     // column allows this.
-    //
-    // MySQL PDO silently casts e.g. FALSE and '' to 0 when inserting the value
-    // into an integer column, but PostgreSQL PDO does not. Also type cast NULL
-    // when the column does not allow this.
     if (isset($object->$field) || !empty($info['not null'])) {
-      if ($info['type'] == 'int' || $info['type'] == 'serial') {
-        $fields[$field] = (int) $fields[$field];
-      }
-      elseif ($info['type'] == 'float') {
-        $fields[$field] = (float) $fields[$field];
-      }
-      else {
-        $fields[$field] = (string) $fields[$field];
-      }
+      $fields[$field] = drupal_schema_get_field_value($info, $fields[$field]);
     }
   }
 
@@ -522,5 +510,33 @@ function drupal_write_record($table, &$record, $primary_keys = array()) {
 }
 
 /**
+ * Type cast to proper datatype.
+ *
+ * MySQL PDO silently casts e.g. FALSE and '' to 0 when inserting the value
+ * into an integer column, but PostgreSQL PDO does not. Also type cast NULL
+ * when the column does not allow this.
+ *
+ * @param array $info
+ *   An array describing the schema field info.
+ * @param mixed $value
+ *   The value to be converted.
+ *
+ * @return mixed
+ *   The converted value.
+ */
+function drupal_schema_get_field_value($info, $value) {
+  if ($info['type'] == 'int' || $info['type'] == 'serial') {
+    $value = (int) $value;
+  }
+  elseif ($info['type'] == 'float') {
+    $value = (float) $value;
+  }
+  else {
+    $value = (string) $value;
+  }
+  return $value;
+}
+
+/**
  * @} End of "addtogroup schemaapi".
  */
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
index 67c3ce2..e1b54c2 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
@@ -546,10 +546,12 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $langcode) {
     // non-translatable properties are replicated for each language.
     $translation = $entity->getTranslation($langcode, FALSE);
 
+    $schema = drupal_get_schema($this->entityInfo['data_table']);
     $record = new \stdClass();
     foreach ($this->entityInfo['schema_fields_sql']['data_table'] as $name) {
       if (isset($translation->$name->value)) {
-        $record->$name = $translation->$name->value;
+        $info = $schema['fields'][$name];
+        $record->$name = drupal_schema_get_field_value($info, $translation->$name->value);
       }
     }
     $record->langcode = $langcode;
diff --git a/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml b/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml
index 690496d..8f0bdee 100644
--- a/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml
+++ b/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml
@@ -56,7 +56,7 @@ display:
       fields:
         title:
           id: title
-          table: node
+          table: node_property_data
           field: title
           label: ''
           alter:
@@ -124,7 +124,7 @@ display:
       filters:
         status:
           value: '1'
-          table: node
+          table: node_property_data
           field: status
           id: status
           expose:
@@ -134,7 +134,7 @@ display:
       sorts:
         created:
           id: created
-          table: node
+          table: node_property_data
           field: created
           order: DESC
           plugin_id: date
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index 40c5aad..dbe3287 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -290,13 +290,13 @@ function book_get_books() {
     if ($nids) {
       $query = db_select('book', 'b', array('fetch' => PDO::FETCH_ASSOC));
       $query->join('node', 'n', 'b.nid = n.nid');
-      $query->join('node_property_data', 'n', 'n.nid = n.nid');
+      $query->join('node_property_data', 'npd', 'npd.nid = n.nid');
       $query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
       $query->addField('n', 'type', 'type');
       $query->fields('b');
       $query->fields('ml');
       $query->condition('n.nid', $nids, 'IN');
-      $query->condition('n.status', 1);
+      $query->condition('npd.status', 1);
       $query->orderBy('ml.weight');
       $query->orderBy('ml.link_title');
       $query->addTag('node_access');
diff --git a/core/modules/entity_reference/tests/modules/entity_reference_test/config/views.view.test_entity_reference.yml b/core/modules/entity_reference/tests/modules/entity_reference_test/config/views.view.test_entity_reference.yml
index ac0fd72..1068be7 100644
--- a/core/modules/entity_reference/tests/modules/entity_reference_test/config/views.view.test_entity_reference.yml
+++ b/core/modules/entity_reference/tests/modules/entity_reference_test/config/views.view.test_entity_reference.yml
@@ -32,7 +32,7 @@ display:
       fields:
         title:
           id: title
-          table: node
+          table: node_property_data
           field: title
           label: ''
           alter:
@@ -50,7 +50,7 @@ display:
       filters:
         status:
           value: '1'
-          table: node
+          table: node_property_data
           field: status
           id: status
           expose:
@@ -59,7 +59,7 @@ display:
       sorts:
         created:
           id: created
-          table: node
+          table: node_property_data
           field: created
           order: DESC
   entity_reference_1:
