def contribute_to_class(self, cls, name): # HACK: remove annoying descriptor (don't super()) RelatedField.contribute_to_class(self, cls, name)
template = '%(expressions)s' arg_joiner = ' - ' arity = 2 def __init__(self, start, end): super(DateDiff, self).__init__(start, end) def as_microsoft(self, compiler, connection): self.template = 'cast(DateDiff(day,%(expressions)s) as float)* -1 *24*60*60*1000.0*1000.0' # Convert to microseconds as used by Django DurationField' self.arg_joiner = ', ' return super(DateDiff, self).as_sql(compiler, connection) def as_sql(self, compiler, connection, function=None, template=None): if connection.vendor is 'microsoft': return self.as_microsoft(compiler, connection) return super(DateDiff, self).as_sql(compiler, connection) class NotEqual(Lookup): lookup_name = 'ne' def as_sql(self, qn, connection): lhs, lhs_params = self.process_lhs(qn, connection) rhs, rhs_params = self.process_rhs(qn, connection) params = lhs_params + rhs_params return '%s != %s' % (lhs, rhs), params Field.register_lookup(NotEqual) RelatedField.register_lookup(NotEqual) ForeignObject.register_lookup(NotEqual) ManyToManyField.register_lookup(NotEqual)
arity = 2 def __init__(self, start, end): super(DateDiff, self).__init__(start, end) def as_microsoft(self, compiler, connection): self.template = 'cast(DateDiff(day,%(expressions)s) as float)* -1 *24*60*60*1000.0*1000.0' # Convert to microseconds as used by Django DurationField' self.arg_joiner = ', ' return super(DateDiff, self).as_sql(compiler, connection) def as_sql(self, compiler, connection, function=None, template=None): if connection.vendor is 'microsoft': return self.as_microsoft(compiler, connection) return super(DateDiff, self).as_sql(compiler, connection) class NotEqual(Lookup): lookup_name = 'ne' def as_sql(self, qn, connection): lhs, lhs_params = self.process_lhs(qn, connection) rhs, rhs_params = self.process_rhs(qn, connection) params = lhs_params + rhs_params return '%s != %s' % (lhs, rhs), params Field.register_lookup(NotEqual) RelatedField.register_lookup(NotEqual) ForeignObject.register_lookup(NotEqual) ManyToManyField.register_lookup(NotEqual)