/**
   * A new object does not have PK assigned yet, therefore by default it is equal only to itself.
   */
  public void testEqualsOnNew() {
    MockModel model1 = new MockModel();
    MockModel model2 = new MockModel();

    assertFalse(model1.equals(model2));
    assertFalse(model2.equals(model1));
    assertTrue(model1.equals(model1)); // equal only to itself
  }
  /** Boolean should handle integer (0/1) and boolean (false/true) values. */
  public void testBooleanColumnType() {
    MockModel mockModel = new MockModel();
    mockModel.booleanField = false;
    Long id = mockModel.save();

    boolean databaseBooleanValue = MockModel.load(MockModel.class, id).booleanField;

    assertEquals(false, databaseBooleanValue);

    // Test passing both a integer and a boolean into the where conditional.
    assertEquals(
        mockModel, new Select().from(MockModel.class).where("booleanField = ?", 0).executeSingle());

    assertEquals(
        mockModel,
        new Select().from(MockModel.class).where("booleanField = ?", false).executeSingle());

    assertNull(new Select().from(MockModel.class).where("booleanField = ?", 1).executeSingle());

    assertNull(new Select().from(MockModel.class).where("booleanField = ?", true).executeSingle());
  }
  /** Two different rows in a table should not be equal (different ids). */
  public void testEqualsDifferentRows() {
    MockModel model1 = new MockModel();
    MockModel model2 = new MockModel();
    MockModel model3;

    model1.save();
    model2.save();
    model3 = Model.load(MockModel.class, model1.getId());

    // Not equal to each other.
    assertFalse(model1.equals(model2));
    assertFalse(model2.equals(model1));

    // Equal to each other when loaded.
    assertTrue(model1.equals(model3));
    assertTrue(model1.equals(model3));

    // Loaded model is not equal to a different model.
    assertFalse(model3.equals(model2));
    assertFalse(model2.equals(model3));
  }
  /** Equals should be type-safe. */
  public void testEqualsNonModel() {
    MockModel model = new MockModel();

    assertFalse(model.equals("Dummy"));
    assertFalse(model.equals(null));
  }