diff --git a/efq_views.module b/efq_views.module
index c4bfd36..68df36a 100644
--- a/efq_views.module
+++ b/efq_views.module
@@ -10,3 +10,34 @@ function efq_views_views_api() {
     'path' => drupal_get_path('module','efq_views'),
   );
 }
+
+/**
+ * Implements hook_query_alter().
+ *
+ * This function excutes methods on queries which are specified by the meta system. This allows modules to,
+ * for instance, add NULL or NOT NULL constraints to a EntityFieldQuery.
+ *
+ * In order to use this functionality, a query needs to be tagged with the 'meta_sql' tag. Besides that
+ * you'll need to specify the methods which must be executed. This is done by calling addMetadata on your
+ * query. In example: $query->addMetaData('meta_sql', array('exampleMethod' => array('param1', 'param2')));
+ *
+ */
+function efq_views_query_meta_sql_alter(QueryAlterableInterface $query) {
+  $extra_sql = $query->getMetaData('meta_sql');
+
+  if (isset($extra_sql)) {
+    foreach ($extra_sql as $method => $arguments) {
+      if (method_exists($query, $method)) {
+        call_user_func_array(array($query, $method), $arguments);
+      }
+      else {
+        watchdog(
+          'efq views',
+          'Method %method does not exist for query object of type %type.',
+          array('%method' => $method, '%type' => get_class($query)),
+          WATCHDOG_WARNING
+        );
+      }
+    }
+  }
+}
