Skip to content

Instantly share code, notes, and snippets.

@mfollett
mfollett / gist:fc1722841ed572d35f75
Created September 25, 2014 21:54
Query to generate query to check foreign key constraints
-- Generates a SQL query that validates that none of your foreign key
-- constrainted columns are invalid (values that don't exist in the column that
-- defines valid values).
-- The query returns a list of foreign key constraints and the number of
-- violations present. If you want this query to return all constraints then
-- you can lop off the 'foo WHERE count > 0' below, this'll cause it to return
-- all foreign key constraints and the number of violations, even when 0.
SELECT 'SELECT * FROM (' || string_agg(query, ' UNION ') || ') foo WHERE count
> 0;' FROM (
SELECT 'SELECT count(*), ' || ''''|| constraint_name || '''' || ' FROM ' || table_name || ' WHERE ' || column_name || ' NOT IN ( SELECT ' || foreign_column_name || ' FROM ' || foreign_table_name || ')' query
@mfollett
mfollett / app.js
Last active August 29, 2015 13:57
Simplest possible AngularJS directive
(function () {
angular.module('simplest', [])
.directive( 'hello', function () {
return {template: '<span>Hello, world!</span>'};
});
})();
client.email = email
client.password = password
client.source = 'my-source'
self.client = False
try:
client.ProgrammaticLogin()
self.client = client
except CaptchaRequired:
rospy.logerr('Google has started requiring captchas for Picasa.')
except BadAuthentication:
class M {
protected foo() { println 'foo' }
}
@Mixin(M) class A {
def bar() { foo() }
}
class B extends A {}
def a = [(4 as Long):4]
def b = [4:4]
assert a == b
def a = [(4 as Long):4]
def b = [4:4]
assert a == b
assert a == b
| | |
| | [4:4]
| false
[4:4]
Long a = 4
Integer b = 4
def map = [(a):1, (b):2]
assert map[a] != map[b]
Long a = 4
Integer b = 4
assert a == b
assert a.class != b.class
addForeignKeyConstraint(
baseColumnNames: 'column_name,
baseTableSchemaName: 'my_schema',
baseTableName: 'my_table',
constraintName: 'my_constraint_name',
deferrable: 'false',
initiallyDeferred: 'false',
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
referencedTableName: 'referenced_table',