| 783 | |
| 784 | #[test] |
| 785 | fn test_schema_builder_build() { |
| 786 | let schema = Schema::builder() |
| 787 | .column("id", DataType::Int(IntType::with_nullable(true))) |
| 788 | .column("name", DataType::Int(IntType::new())) |
| 789 | .primary_key(["id"]) |
| 790 | .option("k", "v") |
| 791 | .comment(Some("table comment".into())) |
| 792 | .build() |
| 793 | .unwrap(); |
| 794 | assert_eq!(schema.fields().len(), 2); |
| 795 | assert_eq!(schema.primary_keys(), &["id"]); |
| 796 | assert_eq!(schema.options().get("k"), Some(&"v".to_string())); |
| 797 | assert_eq!(schema.comment(), Some("table comment")); |
| 798 | let id_field = schema.fields().iter().find(|f| f.name() == "id").unwrap(); |
| 799 | assert!( |
| 800 | !id_field.data_type().is_nullable(), |
| 801 | "primary key column should be normalized to NOT NULL" |
| 802 | ); |
| 803 | } |
| 804 | |
| 805 | #[test] |
| 806 | fn test_schema_validation() { |