File tree Expand file tree Collapse file tree 2 files changed +52
-180
lines changed
test/EFCore.PG.FunctionalTests/Migrations Expand file tree Collapse file tree 2 files changed +52
-180
lines changed Original file line number Diff line number Diff line change @@ -1872,10 +1872,11 @@ protected override void ComputedColumnDefinition(
18721872 throw new NotSupportedException ( "Computed/generated columns aren't supported in PostgreSQL prior to version 12" ) ;
18731873 }
18741874
1875- if ( operation . IsStored != true )
1875+ if ( operation . IsStored is not true && _postgresVersion < new Version ( 18 , 0 ) )
18761876 {
18771877 throw new NotSupportedException (
1878- "Generated columns currently must be stored, specify 'stored: true' in "
1878+ "Virtual (non-stored) generated columns are only supported on PostgreSQL 18 and up. " +
1879+ "On older versions, specify 'stored: true' in "
18791880 + $ "'{ nameof ( RelationalPropertyBuilderExtensions . HasComputedColumnSql ) } ' in your context's OnModelCreating.") ;
18801881 }
18811882
@@ -1894,12 +1895,17 @@ protected override void ComputedColumnDefinition(
18941895 builder
18951896 . Append ( " GENERATED ALWAYS AS (" )
18961897 . Append ( operation . ComputedColumnSql ! )
1897- . Append ( ") STORED " ) ;
1898+ . Append ( ")" ) ;
18981899
1899- if ( ! operation . IsNullable )
1900+ if ( operation . IsStored is true )
19001901 {
1901- builder . Append ( " NOT NULL " ) ;
1902+ builder . Append ( " STORED " ) ;
19021903 }
1904+
1905+ if ( ! operation . IsNullable )
1906+ {
1907+ builder . Append ( " NOT NULL" ) ;
1908+ }
19031909 }
19041910
19051911#pragma warning disable 618
You can’t perform that action at this time.
0 commit comments