This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def truncate_db(engine): | |
# delete all table data (but keep tables) | |
# we do cleanup before test 'cause if previous test errored, | |
# DB can contain dust | |
meta = MetaData(bind=engine, reflect=True) | |
con = engine.connect() | |
trans = con.begin() | |
con.execute('SET FOREIGN_KEY_CHECKS = 0;') | |
for table in meta.sorted_tables: | |
con.execute(table.delete()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { defineAbility } = require('@casl/ability'); | |
const { rulesToQuery } = require('@casl/ability/extra'); | |
const Knex = require('knex'); | |
const { Model } = require('objection'); | |
const { interpret } = require('@ucast/objection') | |
const { CompoundCondition } = require('@ucast/core') | |
const knex = Knex({ | |
client: 'sqlite3', | |
connection: ':memory:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 20111028 jorge@jorgechamorro.com | |
// How to subclass Array | |
// In reply to https://gist.github.com/1100841/9c959db9314338a09c0f288c2c0ca5553816e400 | |
function subArray () { | |
var nu = Array.prototype.slice.apply(arguments); // @grimen: Fixed to support `new Array(666)` (=> `[666]` instead of Array of size 666) | |
nu.__proto__= subArray.prototype; | |
return nu; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Your page</title> | |
</head> | |
<body> | |
<div>Your content</div> | |
<script type="text/javascript"> | |
var mpq=[];mpq.push(["init","0725059687a1080dffb343076224e1b1"]);(function(){var a=document.createElement("script");a.type="text/javascript";a.async=true;a.src=(document.location.protocol==="https:"?"https:":"http:")+"//api.mixpanel.com/site_media/js/api/mixpanel.js";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
width: 100%; | |
height: 100%; | |
} | |
body { | |
outline: 1px dashed rgba(0, 0, 0, 0.2); | |
} | |
body:before { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One other cause is your :dependent callbacks. | |
class Blog < AR::Base | |
has_many :posts, :dependent => :destroy | |
end | |
This will iterate through every post and call #destroy on it. Use :delete_all if you want to just issue a single delete query. HOWEVER, this won't hit your destroy callbacks on Post. | |
class Blog < AR::Base | |
has_many :posts |