marioosh.net

mini blog / notes

updateValueAndValidity();

updateValueAndValidity() works for control, but NOT for children ! form:FormGroup; constructor(private fb:FormBuilder) { }   initForm() { this.form = this.fb.group({ ‘files’:[”, [this.fv.bind(this)]] }); }   /** * my validator */ fv(fc:AbstractControl) { console.log(’validate’, fc); // … }   /** * func that need to revalidate ‘files’ field */ someFunc() { // … this.form.updateValueAndValidity(); // NOT Read more about updateValueAndValidity();[…]

Change commit date

$ git rebase -i HEAD~3   In editor mark commit that need change as ‘edit’ (the second commit in example below)   pick 64b0966 commit message 1… edit 07f540b commit message 2… pick a2b69e4 commit message 3…   # Rebase 50d9975..a2b69e4 onto 50d9975 (3 command(s)) # # Commands: # p, pick = use commit # Read more about Change commit date[…]

Posted in git

rx.js – chain requests

import { mergeMap } from ‘rxjs/operators’;   this.http.get(’/request1’).pipe( mergeMap((resp1:any) => this.http.post(’/request2′, resp1) ) );import { mergeMap } from ‘rxjs/operators’; this.http.get(‘/request1’).pipe( mergeMap((resp1:any) => this.http.post(‘/request2’, resp1) ) );

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value (Konwersja typu danych varchar na typ danych datetime spowodowała utworzenie wartości leżącej poza zakresem)

This error can be result of wrong `dateformat` setting on database. Example below. ERROR – `dmy` dateformat: SET DATEFORMAT dmy; DECLARE @datetime datetime = ‘2021-12-31’; SELECT CASE WHEN @datetime >= ‘2021-11-22’ THEN 1 ELSE 0 END;SET DATEFORMAT dmy; DECLARE @datetime datetime = ‘2021-12-31’; SELECT case when @datetime >= ‘2021-11-22’ then 1 else 0 end; OK Read more about The conversion of a varchar data type to a datetime data type resulted in an out-of-range value (Konwersja typu danych varchar na typ danych datetime spowodowała utworzenie wartości leżącej poza zakresem)[…]

Native query with Enum as parameter

public interface ItemRepository extends JpaRepository<Item, Long> { @Query(value = "select * from items where type = :#{#type?.name()}", nativeQuery = true) List<Item> findByType(@Param("type") ItemType type); }   public enum ItemType { NORMAL, LARGE };public interface ItemRepository extends JpaRepository<Item, Long> { @Query(value = "select * from items where type = :#{#type?.name()}", nativeQuery = true) List<Item> findByType(@Param("type") ItemType Read more about Native query with Enum as parameter[…]

Optional @Value

// default: 60 @Value("${test-value:60}") private int minutes;   // default: null @Value("${test-value2:#{null}}") private String text;// default: 60 @Value("${test-value:60}") private int minutes; // default: null @Value("${test-value2:#{null}}") private String text;

Map<String,String> in JPA Entity

@Entity @Table(name="product") public class Product extends AbstractEntity {   @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id;   @ElementCollection(fetch = FetchType.EAGER) @JoinTable(name="product_attribute", joinColumns=@JoinColumn(name="product_id")) @MapKeyColumn(name="key") @Column(name="value") private Map<String, String> attributes = new HashMap<String, String>();   // …   }@Entity @Table(name="product") public class Product extends AbstractEntity { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ElementCollection(fetch = FetchType.EAGER) @JoinTable(name="product_attribute", joinColumns=@JoinColumn(name="product_id")) @MapKeyColumn(name="key") @Column(name="value") private Read more about Map<String,String> in JPA Entity[…]