constraints

Rails 3 Problem with Routes Constraint

本秂侑毒 提交于 2019-12-02 00:57:19
I'm trying to make it so that I can have a urls like this: /events /events/sunday # => The day is optional However, it doesn't seem to be working even though I know it is getting called. It is at the bottom of my routes file. match '/:post(/:day_filter)' => 'posts#index', :as => post_day_filter, :constraints => DayFilter.new class DayFilter def initialize @days = %w[all today tomorrow sunday monday tuesday wednesday thursday friday saturday] end def matches?(request) return @days.include?(request.params[:day_filter]) if request.params[:day_filter] true end end Here is my rake routes output:

iOS - Placing two label together in centre of their super view

杀马特。学长 韩版系。学妹 提交于 2019-12-02 00:50:02
I have two label, L1 and L2 of variable and nonidentical length. I want to place these two label using constraints in Xcode. If possible i don't want to manipulate constraints programmatically. guidance will be appreciated. Right image should be the expected output Requirements, Two labels are non identical in width When running leading space of L1 and trailing space of L2 will be equal distance between L1 & L2, horizontal space is fixed, 10 px UIStackView cannot be used How can I do it from Xcode? What you can do is put both the UILabel inside a UIView and then: Add a leading, top and bottom

Deleting from a MySQL table with foreign key constraints

岁酱吖の 提交于 2019-12-02 00:04:36
问题 I have two tables, with some data loaded in it and the two reference each other. Table B references the primary key of Table A. I manually attempt to delete some table rows from Table A that are present in Table B, and I get this: #1451 - Cannot delete or update a parent row: a foreign key constraint fails ( TableA . TableB , CONSTRAINT TableB_ibfk_2 FOREIGN KEY ( column ) REFERENCES flashcard ( primaryKeyColumn )) I am not quite sure what's up here. From what I understand,if I delete some

Shapeless: own HList constraint using Coproduct

假如想象 提交于 2019-12-01 23:08:50
(NOTE: Split from Shapeless: Trying to restrict HList elements by their type ) Question 2 - Own Constraint using Coproduct What I really wanted to do is to write a new constraint using Coproduct. trait CPConstraint[L <: HList, CP <: Coproduct] extends Serializable object CPConstraint { import shapeless.ops.coproduct.Selector._ def apply[L <: HList, CP <: Coproduct](implicit cpc: CPConstraint[L, CP]): CPConstraint[L, CP] = cpc type <*<[CP <: Coproduct] = { // TODO: just invented a symbol ... what would be an appropriate one? type λ[L <: HList] = CPConstraint[L, CP] } implicit def hnilCP[HN <:

SQL Server check constraint failing on correct input

走远了吗. 提交于 2019-12-01 22:29:42
I'm using a check constraint on a table to restrict what values are inserted in the table.. Here's an explanation of what I'm trying to do If any Product(sedan) is associated to a specific ObjLevel (Toyota) then the same Product cannot be associated to another specific ObjLevel (Lexus) After I apply the check constraint on the table, any insert containing ObjLevel "toyota" or "lexus" fails.. create table ObjLevel( OLID int identity, Name varchar(50) not null ) insert into ObjLevel values('Ford') insert into ObjLevel values('Toyota') insert into ObjLevel values('Lexus') insert into ObjLevel

How do I 'DROP' and unamed relationship/constraint in MS Access with SQL?

柔情痞子 提交于 2019-12-01 21:40:45
问题 I have a Microsoft Access database and I have two tables. Table1 has a primary key and Table2 has a foreign key that references Table1's primary key. This relationship is set up and viewable in the Relationship viewer in MS Access, the 'Enforce Referential Integrity' check box is checked, and the Join type is an inner join. The relationship is: [Table1]--1---------N--[Table2] I need to be able to 'DROP' this relationship/constraint via SQL. How do I do this? I have no name for this

Oracle SQL - can CASE be used in a check constraint to determine data attributes?

坚强是说给别人听的谎言 提交于 2019-12-01 21:25:15
问题 I'm using Oracle 10g and I want to apply a constraint to a table where the value entered for one column determines whether another column IS NULL or IS NOT NULL. Column1 can only contain 1 or 0; Column2 is VARCHAR2(255). I know that the following works: CONSTRAINT ck_1 CHECK ((col1=1 AND col2 IS NOT NULL) OR (col1=0 AND col2 IS NULL)); However, I was wondering if it is possible to use CASE to perform this constraint and set the attribute NOT NULL on col2, or can CASE only be used to define

Trigger to silently ignore/delete duplicate entries on INSERT

谁都会走 提交于 2019-12-01 21:18:36
I have the following table: T(ID primary key, A, B) I want to have pair (A, B) unique but I don't want to have constraint unique(A,B) on them because it will give error on insert. Instead I want MySQL to silently ignore such inserts. I can't use "insert on duplicate keys ignore" because I can't control client's queries. So, can I build such trigger? Or maybe there is some constraint that allows silent ignore? Edit: I dug around and I think I want something like SQLite's "Raise Ignore" statement. Before mysql 5.5. it wasn't possible to stop an insert inside a trigger. There where some ugly work

Grails 2.1 Unit Testing Command Object mockForConstraintsTests not working?

烈酒焚心 提交于 2019-12-01 21:17:06
I have used manually written as well as Grails generated Unit tests for this command object: package myapp @grails.validation.Validateable class SearchCommand { String basisBuild String buildToSearch static constraints = { basisBuild(blank: false) } } After having my hand written unit test fail I used Grails: create-unit-test myapp.SearchCommand I filled in the Unit Test, and made an assertion that should pass per documentation on mocked constraints: package myapp import static org.junit.Assert.* import grails.test.mixin.* import grails.test.mixin.support.* import org.junit.* @TestMixin

Deleting from a MySQL table with foreign key constraints

孤者浪人 提交于 2019-12-01 21:14:09
I have two tables, with some data loaded in it and the two reference each other. Table B references the primary key of Table A. I manually attempt to delete some table rows from Table A that are present in Table B, and I get this: #1451 - Cannot delete or update a parent row: a foreign key constraint fails ( TableA . TableB , CONSTRAINT TableB_ibfk_2 FOREIGN KEY ( column ) REFERENCES flashcard ( primaryKeyColumn )) I am not quite sure what's up here. From what I understand,if I delete some rows of TableA then they should automatically also delete the corresponding rows present in Table B (i.e