问:
cannot resolve this error: unable to insert NULL in ("NAWFEL". "ORDO_DEP_UUSATEUR". "EMPLOI")
I'm developing a user registration form, the problem I get is that when I want to test my web service in postman it shows me the following error in my eclipse console:

```<code> 2020-06-02 19:50:04.559  WARN 1576 --- [nio-8484-exec-2]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1400, SQLState:
> 23000 2020-06-02 19:50:04.560 ERROR 1576 --- [nio-8484-exec-2]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : ORA-01400: impossible
> d'insérer NULL dans ("NAWFEL"."ORDO_DEP_UTILISATEUR"."EMPLOI")
>
> 2020-06-02 19:50:04.582 ERROR 1576 --- [nio-8484-exec-2]
> o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for
> servlet [dispatcherServlet] in context with path [] threw exception
> [Request processing failed; nested exception is
> org.springframework.dao.DataIntegrityViolationException: could not
> execute statement; SQL [n/a]; constraint [null]; nested exception is
> org.hibernate.exception.ConstraintViolationException: could not
> execute statement] with root cause
>
> oracle.jdbc.OracleDatabaseException: ORA-01400: impossible d'insérer
> NULL dans ("NAWFEL"."ORDO_DEP_UTILISATEUR"."EMPLOI")
>
>   at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:513)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:461)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1104)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:550)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]
</code>```

he tells me that I cannot insert a null value in the job "emploi" column, but I entered the value of the job column in my postman as you can see here:

this is my entity code :

```<code>package com.app.habilitation.entity;

import java.sql.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="ORDO_DEP_UTILISATEUR")
public class UserEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="IDENTIFIANT")
    private Integer IDENTIFIANT;

    @ManyToOne(cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
    @JoinColumn(name="EMPLOI")

    private EmploiEntity emploi;

    @ManyToOne(cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
    @JoinColumn(name="ENTITE")

    private EntiteEntity entite;

    @Column(name="LOGIN")
    private String login;

    @Column(name="MOTDEPASSE")
    private String mdp;

    @Column(name="NOM")
    private String nom;

    @Column(name="PRENOM")
    private String prenom;

    @Column(name="CREEPAR")
    private Integer creerpar;

    @Column(name="ANNULEPAR")
    private Integer annulepar;

    @Column(name="STATUT")
    private String statut;

    @Column(name="DATEEFFET")
    private Date dateeffet;

    @Column(name="DATEFIN")
    private Date datefin;

    @Column(name="CREELE")
    private Date creele;

    @Column(name="MOTIFDEDESACTIVATION")
    private String motifdedesactivation;

    @Column(name="ANNULELE")
    private Date annulele;

    @Column(name="EMAIL")
    private String email;

    @Column(name="CONFIRMATIONMOTDEPASSE")
    private String confirmation_mot_de_passe;

    public String getConfirmation_mot_de_passe() {
        return confirmation_mot_de_passe;
    }

    public void setConfirmation_mot_de_passe(String confirmation_mot_de_passe) {
        this.confirmation_mot_de_passe = confirmation_mot_de_passe;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getIDENTIFIANT() {
        return IDENTIFIANT;
    }

    public void setIDENTIFIANT(Integer iDENTIFIANT) {
        IDENTIFIANT = iDENTIFIANT;
    }

    public EmploiEntity getEmploi() {
        return emploi;
    }

    public void setEmploi(EmploiEntity emploi) {
        this.emploi = emploi;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getMdp() {
        return mdp;
    }

    public void setMdp(String mdp) {
        this.mdp = mdp;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public Integer getCreerpar() {
        return creerpar;
    }

    public void setCreerpar(Integer creerpar) {
        this.creerpar = creerpar;
    }

    public Integer getAnnulepar() {
        return annulepar;
    }

    public void setAnnulepar(Integer annulepar) {
        this.annulepar = annulepar;
    }

    public String getStatut() {
        return statut;
    }

    public void setStatut(String statut) {
        this.statut = statut;
    }

    public Date getDateeffet() {
        return dateeffet;
    }

    public void setDateeffet(Date dateeffet) {
        this.dateeffet = dateeffet;
    }

    public Date getDatefin() {
        return datefin;
    }

    public void setDatefin(Date datefin) {
        this.datefin = datefin;
    }

    public Date getCreele() {
        return creele;
    }

    public void setCreele(Date creele) {
        this.creele = creele;
    }

    public String getMotifdedesactivation() {
        return motifdedesactivation;
    }

    public void setMotifdedesactivation(String motifdedesactivation) {
        this.motifdedesactivation = motifdedesactivation;
    }

    public Date getAnnulele() {
        return annulele;
    }

    public void setAnnulele(Date annulele) {
        this.annulele = annulele;
    }

    public EntiteEntity getEntite() {
        return entite;
    }

    public void setEntite(EntiteEntity entite) {
        this.entite = entite;
    }

    public UserEntity(EmploiEntity emploi, EntiteEntity entite, String login, String mdp, String nom, String prenom,
            Integer creerpar, Integer annulepar, String statut, Date dateeffet, Date datefin, Date creele,
            String motifdedesactivation, Date annulele, String email, String confirmation_mot_de_passe) {
        this.emploi = emploi;
        this.entite = entite;
        this.login = login;
        this.mdp = mdp;
        this.nom = nom;
        this.prenom = prenom;
        this.creerpar = creerpar;
        this.annulepar = annulepar;
        this.statut = statut;
        this.dateeffet = dateeffet;
        this.datefin = datefin;
        this.creele = creele;
        this.motifdedesactivation = motifdedesactivation;
        this.annulele = annulele;
        this.email = email;
        this.confirmation_mot_de_passe = confirmation_mot_de_passe;
    }

    public UserEntity() {
    }

    @Override
    public String toString() {
        return "UserEntity [IDENTIFIANT=" + IDENTIFIANT + ", emploi=" + emploi + ", entite=" + entite + ", login="
                + login + ", mdp=" + mdp + ", nom=" + nom + ", prenom=" + prenom + ", creerpar=" + creerpar
                + ", annulepar=" + annulepar + ", statut=" + statut + ", dateeffet=" + dateeffet + ", datefin="
                + datefin + ", creele=" + creele + ", motifdedesactivation=" + motifdedesactivation + ", annulele="
                + annulele + ", email=" + email + ", confirmation_mot_de_passe=" + confirmation_mot_de_passe + "]";
    }

}
</code>```

and this is my dao ( i use jpa) :

```<code>package com.app.habilitation.dao;

import org.springframework.data.jpa.repository.JpaRepository;

import com.app.habilitation.entity.UserEntity;

public interface UserDao extends JpaRepository<UserEntity, Integer> {

}
</code>```

and this is my userService :

```<code>package com.app.habilitation.service;

import java.util.List;

import com.app.habilitation.entity.UserEntity;

public interface UserService {

    public void save (UserEntity theUser);

}
</code>```

and this is my userServiceImpl :

```<code>package com.app.habilitation.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.app.habilitation.dao.UserDao;
import com.app.habilitation.entity.UserEntity;

@Service
public class UserServiceImpl implements UserService {

    private UserDao userDao;

    @Autowired

    public UserServiceImpl (UserDao theuserDao) {

        userDao = theuserDao;
    }

    @Override
    @Transactional
    public void save(UserEntity theUser) {

        userDao.save(theUser);

    }

}
</code>```

and this is my controller :

```<code>package com.app.habilitation.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.app.habilitation.entity.UserEntity;
import com.app.habilitation.service.UserService;

@SpringBootApplication
@RestController
@CrossOrigin(origins = "*")
//@RequestMapping("/user")
public class UserController {

    private UserService userService;

    @Autowired
    public UserController (UserService theuserService) {
        userService=theuserService;
    }

    @GetMapping("/")
    public String login() {
        return "authenticaated succesfully";
    }

    @GetMapping("/getUsers")
    public String getUsers() {
        return "users";
    }

    @PostMapping("/addUser")
    public UserEntity addUser (@RequestBody UserEntity theUser) {

        System.out.println("test");
        userService.save(theUser);

        return theUser;
    }
}
</code>```

and this is my table user (i use oracle 10g) :

can someone help me please ??

答:
Can you try to send them as an objects like this</p>

```<code>{
   "emploi":{"IDENTIFIANT":1}
    // and so on for any object
}
</code>```

Body:
I'm developing a user registration form, the problem I get is that when I want to test my web service in postman it shows me the following error in my eclipse console:

 2020-06-02 19:50:04.559  WARN 1576 --- [nio-8484-exec-2]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1400, SQLState:
> 23000 2020-06-02 19:50:04.560 ERROR 1576 --- [nio-8484-exec-2]
> o.h.engine.jdbc.spi.SqlExceptionHelper   : ORA-01400: impossible
> d'insérer NULL dans ("NAWFEL"."ORDO_DEP_UTILISATEUR"."EMPLOI")
>
> 2020-06-02 19:50:04.582 ERROR 1576 --- [nio-8484-exec-2]
> o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for
> servlet [dispatcherServlet] in context with path [] threw exception
> [Request processing failed; nested exception is
> org.springframework.dao.DataIntegrityViolationException: could not
> execute statement; SQL [n/a]; constraint [null]; nested exception is
> org.hibernate.exception.ConstraintViolationException: could not
> execute statement] with root cause
>
> oracle.jdbc.OracleDatabaseException: ORA-01400: impossible d'insérer
> NULL dans ("NAWFEL"."ORDO_DEP_UTILISATEUR"."EMPLOI")
>
>   at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:513)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:461)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1104)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:550)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]     at
> oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
> ~[ojdbc8-19.3.0.0.jar:19.3.0.0.0]

he tells me that I cannot insert a null value in the job "emploi" column, but I entered the value of the job column in my postman as you can see here:

this is my entity code :

package com.app.habilitation.entity;

import java.sql.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="ORDO_DEP_UTILISATEUR")
public class UserEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="IDENTIFIANT")
    private Integer IDENTIFIANT;

    @ManyToOne(cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
    @JoinColumn(name="EMPLOI")

    private EmploiEntity emploi;

    @ManyToOne(cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
    @JoinColumn(name="ENTITE")

    private EntiteEntity entite;

    @Column(name="LOGIN")
    private String login;

    @Column(name="MOTDEPASSE")
    private String mdp;

    @Column(name="NOM")
    private String nom;

    @Column(name="PRENOM")
    private String prenom;

    @Column(name="CREEPAR")
    private Integer creerpar;

    @Column(name="ANNULEPAR")
    private Integer annulepar;

    @Column(name="STATUT")
    private String statut;

    @Column(name="DATEEFFET")
    private Date dateeffet;

    @Column(name="DATEFIN")
    private Date datefin;

    @Column(name="CREELE")
    private Date creele;

    @Column(name="MOTIFDEDESACTIVATION")
    private String motifdedesactivation;

    @Column(name="ANNULELE")
    private Date annulele;

    @Column(name="EMAIL")
    private String email;

    @Column(name="CONFIRMATIONMOTDEPASSE")
    private String confirmation_mot_de_passe;

    public String getConfirmation_mot_de_passe() {
        return confirmation_mot_de_passe;
    }

    public void setConfirmation_mot_de_passe(String confirmation_mot_de_passe) {
        this.confirmation_mot_de_passe = confirmation_mot_de_passe;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getIDENTIFIANT() {
        return IDENTIFIANT;
    }

    public void setIDENTIFIANT(Integer iDENTIFIANT) {
        IDENTIFIANT = iDENTIFIANT;
    }

    public EmploiEntity getEmploi() {
        return emploi;
    }

    public void setEmploi(EmploiEntity emploi) {
        this.emploi = emploi;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getMdp() {
        return mdp;
    }

    public void setMdp(String mdp) {
        this.mdp = mdp;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public Integer getCreerpar() {
        return creerpar;
    }

    public void setCreerpar(Integer creerpar) {
        this.creerpar = creerpar;
    }

    public Integer getAnnulepar() {
        return annulepar;
    }

    public void setAnnulepar(Integer annulepar) {
        this.annulepar = annulepar;
    }

    public String getStatut() {
        return statut;
    }

    public void setStatut(String statut) {
        this.statut = statut;
    }

    public Date getDateeffet() {
        return dateeffet;
    }

    public void setDateeffet(Date dateeffet) {
        this.dateeffet = dateeffet;
    }

    public Date getDatefin() {
        return datefin;
    }

    public void setDatefin(Date datefin) {
        this.datefin = datefin;
    }

    public Date getCreele() {
        return creele;
    }

    public void setCreele(Date creele) {
        this.creele = creele;
    }

    public String getMotifdedesactivation() {
        return motifdedesactivation;
    }

    public void setMotifdedesactivation(String motifdedesactivation) {
        this.motifdedesactivation = motifdedesactivation;
    }

    public Date getAnnulele() {
        return annulele;
    }

    public void setAnnulele(Date annulele) {
        this.annulele = annulele;
    }

    public EntiteEntity getEntite() {
        return entite;
    }

    public void setEntite(EntiteEntity entite) {
        this.entite = entite;
    }

    public UserEntity(EmploiEntity emploi, EntiteEntity entite, String login, String mdp, String nom, String prenom,
            Integer creerpar, Integer annulepar, String statut, Date dateeffet, Date datefin, Date creele,
            String motifdedesactivation, Date annulele, String email, String confirmation_mot_de_passe) {
        this.emploi = emploi;
        this.entite = entite;
        this.login = login;
        this.mdp = mdp;
        this.nom = nom;
        this.prenom = prenom;
        this.creerpar = creerpar;
        this.annulepar = annulepar;
        this.statut = statut;
        this.dateeffet = dateeffet;
        this.datefin = datefin;
        this.creele = creele;
        this.motifdedesactivation = motifdedesactivation;
        this.annulele = annulele;
        this.email = email;
        this.confirmation_mot_de_passe = confirmation_mot_de_passe;
    }

    public UserEntity() {
    }

    @Override
    public String toString() {
        return "UserEntity [IDENTIFIANT=" + IDENTIFIANT + ", emploi=" + emploi + ", entite=" + entite + ", login="
                + login + ", mdp=" + mdp + ", nom=" + nom + ", prenom=" + prenom + ", creerpar=" + creerpar
                + ", annulepar=" + annulepar + ", statut=" + statut + ", dateeffet=" + dateeffet + ", datefin="
                + datefin + ", creele=" + creele + ", motifdedesactivation=" + motifdedesactivation + ", annulele="
                + annulele + ", email=" + email + ", confirmation_mot_de_passe=" + confirmation_mot_de_passe + "]";
    }

}

and this is my dao ( i use jpa) :

package com.app.habilitation.dao;

import org.springframework.data.jpa.repository.JpaRepository;

import com.app.habilitation.entity.UserEntity;

public interface UserDao extends JpaRepository<UserEntity, Integer> {

}

and this is my userService :

package com.app.habilitation.service;

import java.util.List;

import com.app.habilitation.entity.UserEntity;

public interface UserService {

    public void save (UserEntity theUser);

}

and this is my userServiceImpl :

package com.app.habilitation.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.app.habilitation.dao.UserDao;
import com.app.habilitation.entity.UserEntity;

@Service
public class UserServiceImpl implements UserService {

    private UserDao userDao;

    @Autowired

    public UserServiceImpl (UserDao theuserDao) {

        userDao = theuserDao;
    }

    @Override
    @Transactional
    public void save(UserEntity theUser) {

        userDao.save(theUser);

    }

}

and this is my controller :

package com.app.habilitation.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.app.habilitation.entity.UserEntity;
import com.app.habilitation.service.UserService;

@SpringBootApplication
@RestController
@CrossOrigin(origins = "*")
//@RequestMapping("/user")
public class UserController {

    private UserService userService;

    @Autowired
    public UserController (UserService theuserService) {
        userService=theuserService;
    }

    @GetMapping("/")
    public String login() {
        return "authenticaated succesfully";
    }

    @GetMapping("/getUsers")
    public String getUsers() {
        return "users";
    }

    @PostMapping("/addUser")
    public UserEntity addUser (@RequestBody UserEntity theUser) {

        System.out.println("test");
        userService.save(theUser);

        return theUser;
    }
}

and this is my table user (i use oracle 10g) :

can someone help me please ??

Body:
Can you try to send them as an objects like this

{
   "emploi":{"IDENTIFIANT":1}
    // and so on for any object
}


来源: stackexchange

问:
How do you use "all()" in a conditional in python?
For example, if A were a list of ints, and I wanted to say "if every element of A is equal to 3, then...etc"

```<code>if all(A) == 3:
    #then do this
</code>```

Not quite sure of the syntax or how to express it. Thanks in advance!

答:
```<code>if all(a == 3 for a in A):
    pass
</code>```

For testing that all items in a collection are identical, another fun option is to use a set:

```<code>if set(A) == {3}:
    pass
</code>```

ContentLicense: CC BY-SA 4.0

Body:
For example, if A were a list of ints, and I wanted to say "if every element of A is equal to 3, then...etc"

if all(A) == 3:
    #then do this

Not quite sure of the syntax or how to express it. Thanks in advance!

Body:
if all(a == 3 for a in A):
    pass

For testing that all items in a collection are identical, another fun option is to use a set:

if set(A) == {3}:
    pass


问:
Character array initialization with the first element being null
I was recently faced with a line of code and four options:

```<code>char fullName[30] = {NULL};
</code>```

A) First element is assigned a NULL character.

B) Every element of the array is assigned 0 ( Zeroes )

C) Every element of the array is assigned NULL

D) The array is empty.

The answer we selected was option C, as, while the array is only initialized with a single NULL, C++ populates the rest of the array with NULL.

However, our professor disagreed, stating that the answer is A, he said:

So the very first element is NULL, and when you display it, it's displaying the first element, which is NULL.

The quote shows the question in its entirety; there was no other information provided. I'm curious to which one is correct, and if someone could explain why said answer would be correct.

答:
Apparently, Your Professor is right, let's see how

char someName[6] = "SAAD";

how the string name is represented in memory:

0 1 2 3 4 5

S A A D

Array-based C string

The individual characters that make up the string are stored in the elements of the array. The string is terminated by a null character. Array elements after the null character are not part of the string, and their contents are irrelevant.

A "null string" is a string with a null character as its first character:

0 1 2 3 4 5

/0

Null C string

The length of a null string is 0.

Body:
I was recently faced with a line of code and four options:

char fullName[30] = {NULL};

A) First element is assigned a NULL character.

B) Every element of the array is assigned 0 ( Zeroes )

C) Every element of the array is assigned NULL

D) The array is empty.

The answer we selected was option C, as, while the array is only initialized with a single NULL, C++ populates the rest of the array with NULL.

However, our professor disagreed, stating that the answer is A, he said:

So the very first element is NULL, and when you display it, it's displaying the first element, which is NULL.

The quote shows the question in its entirety; there was no other information provided. I'm curious to which one is correct, and if someone could explain why said answer would be correct.


问:
Postgresql query deletes all rows
I wrote a simple delete query in a PostgreSQL function with using clause, left join and a where clause. But the query does not take the where condition in consideration. It deletes all rows.

I wrote two types of query both produce same result

Query 1

```<code>delete from "StockInfos" using "StockInfos" as si
    left outer join "PurchaseOrderInfos" as poi on poi."Id" = si."PurchaseOrderInfoId"
    left outer join "ReceivingInfos" as ri on ri."PurchaseOrderInfoId" = poi."Id"
 where ri."Id" = (delete_data->>'Id')::bigint;
</code>```

Query 2

```<code>delete from "StockInfos" where exists (
            select * from "StockInfos" as si
                left join "PurchaseOrderInfos" as poi on poi."Id" = si."PurchaseOrderInfoId"
                left outer join "ReceivingInfos" as ri on ri."PurchaseOrderInfoId" = poi."Id"
            where ri."Id" = (delete_data->>'Id')::bigint
        );
</code>```

I don understand what is the problem. May anyone tell what is going wrong?

答:
I would rephrase this with a correlated subquery. This makes the logic much cleaner, and should do what you want:</p>

```<code>delete from "StockInfos" si
where exists (
    select 1
    from "PurchaseOrderInfos" poi
    inner join "ReceivingInfos" as ri on ri."PurchaseOrderInfoId" = poi."Id"
    where
        oi."Id" = si."PurchaseOrderInfoId"
        and ri."Id" = (si.delete_data->>'Id')::bigint

)
</code>```

Title: Postgresql query deletes all rows

Body:
I wrote a simple delete query in a PostgreSQL function with using clause, left join and a where clause. But the query does not take the where condition in consideration. It deletes all rows.

I wrote two types of query both produce same result

Query 1

delete from "StockInfos" using "StockInfos" as si
    left outer join "PurchaseOrderInfos" as poi on poi."Id" = si."PurchaseOrderInfoId"
    left outer join "ReceivingInfos" as ri on ri."PurchaseOrderInfoId" = poi."Id"
 where ri."Id" = (delete_data->>'Id')::bigint;

Query 2

delete from "StockInfos" where exists (
            select * from "StockInfos" as si
                left join "PurchaseOrderInfos" as poi on poi."Id" = si."PurchaseOrderInfoId"
                left outer join "ReceivingInfos" as ri on ri."PurchaseOrderInfoId" = poi."Id"
            where ri."Id" = (delete_data->>'Id')::bigint
        );

I don understand what is the problem. May anyone tell what is going wrong?

Body:
I would rephrase this with a correlated subquery. This makes the logic much cleaner, and should do what you want:

delete from "StockInfos" si
where exists (
    select 1
    from "PurchaseOrderInfos" poi
    inner join "ReceivingInfos" as ri on ri."PurchaseOrderInfoId" = poi."Id"
    where
        oi."Id" = si."PurchaseOrderInfoId"
        and ri."Id" = (si.delete_data->>'Id')::bigint

)


问:
How to squash all commits except the n most recent?
I see you can do git rebase -i HEAD~3 to handle the latest 3 commits. Is there a way to simply squash every commit before, say, the latest 3 commits without manually going through all the commits and specifying squash?

For context, I created a branch (testBranch) off a branch (originalBranch). I made a bunch of commits, and now I want to merge this branch to the master branch. The problem is, I have all the commits from originalBranch.
I've even tried rebasing by doing git rebase -i HEAD~70 (yes, there were a lot of commits in originalBranch), and editing the file as so:

```<code>r 14133a8 first commit message in originalBranch
s 3cb3a90 message2
s ea61cc4 message3
# ... etc
#commits from testBranch. These should remain after rebase
p a62bff7 first commit message in testBranch
p 4364e1f last commit message in testBranch
</code>```

I though everything from originalBranch would squash into one message, but I get file conflicts when I do this. How can I simply squash every commit from originalBranch into 1 commit message while keeping the commit messages from testBranch, without file conflicts?

答:
Well... you can squash rather easily like this.

```<code>git checkout --detach originalBranch
# set branch pointer at the point where originalBranch and master diverged
git reset --soft $( git merge-base HEAD master ) # all changes are ready to be committed
git commit -m "Squashed originalBranch"
# now we replicate your branch on top of it
git cherry-pick originalBranch..testBranch # replicated all changes on top of squashed revision
# now you can consider moving your branch if you like the result
git branch -f testBranch
git checkout testBranch
</code>```

But do you really need to do that? That's not elegant at all. If you don't depend on originalBranch and you only want to move to the top of master:

```<code>git rebase --onto master originalBranch testBranch
</code>```

That will move the revisions that are from testBranch that are not in originalBranch on top of master.

Body:
I see you can do git rebase -i HEAD~3 to handle the latest 3 commits. Is there a way to simply squash every commit before, say, the latest 3 commits without manually going through all the commits and specifying squash?

For context, I created a branch (testBranch) off a branch (originalBranch). I made a bunch of commits, and now I want to merge this branch to the master branch. The problem is, I have all the commits from originalBranch.
I've even tried rebasing by doing git rebase -i HEAD~70 (yes, there were a lot of commits in originalBranch), and editing the file as so:

r 14133a8 first commit message in originalBranch
s 3cb3a90 message2
s ea61cc4 message3
# ... etc
#commits from testBranch. These should remain after rebase
p a62bff7 first commit message in testBranch
p 4364e1f last commit message in testBranch

I though everything from originalBranch would squash into one message, but I get file conflicts when I do this. How can I simply squash every commit from originalBranch into 1 commit message while keeping the commit messages from testBranch, without file conflicts?

Body:
Well... you can squash rather easily like this.

git checkout --detach originalBranch
# set branch pointer at the point where originalBranch and master diverged
git reset --soft $( git merge-base HEAD master ) # all changes are ready to be committed
git commit -m "Squashed originalBranch"
# now we replicate your branch on top of it
git cherry-pick originalBranch..testBranch # replicated all changes on top of squashed revision
# now you can consider moving your branch if you like the result
git branch -f testBranch
git checkout testBranch

But do you really need to do that? That's not elegant at all. If you don't depend on originalBranch and you only want to move to the top of master:

git rebase --onto master originalBranch testBranch

That will move the revisions that are from testBranch that are not in originalBranch on top of master.


问:
Jquery Send Ajax and no wait response for sending other ajax
I have an ajax that call to a server and run a long process (this process is writing the status on a database).

I have other ajax (recursively) to get the status of the long process and set the params on a Progress Bar.

My problem is that the second ajax not start until the first one finishes. Is there a way to send the first ajax and no wait for a response?

Any ideas?

I appreciate any suggestion, I am a little bit tired about this issue.

If there is another method to send a long process and get the status of the long process, tell me, please.

Thank you!

This is my code, in case it's helps

executeProgressBar(1, token);

$.ajax({
  type: "POST",
  enctype: 'multipart/form-data',
  processData: false,
  contentType: false,
  cache: false,
  url: "/long_process",
  data: form_data,
  success: function (response) {
    //NOTHING
  }
});

function executeProgressBar(start, token) {

  if (start == 1) {

    //reset progress bar
    $('.progress-bar').css('width', '0%');
    $('.progress-bar').text('0%');
    $('.progress-bar').attr('data-progress', '0');

  }

  $.ajax({
    type: "POST",
    url: "/progress_bar_status",
    data: { token: token, sleep: 0 },
    success: function (response) {

      $('.progress-bar').css('width', response['percentage'] + '%');
      $('.progress-bar').text(response['percentage'] + '%');
      $('.progress-bar').attr('data-progress', response['percentage']);

      $('#done').text(response['executed']);
      $('.execute-time').text('tiempo');

      if (response.percentage == 100) {
        $('.end-process').show();
      } else {
        executeProgressBar(0, token);
      }
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      if (textStatus == 'parsererror') {
        textStatus = 'Technical error: Unexpected response returned by server. Sending stopped.';
      }
      alert(textStatus);
    }
  });
}
```

<p><strong>EDIT</strong></p>

<p>I solved whit this code on the server side - php </p>

```        /************** Close connection and return echo message **************/
        ob_end_clean();
        header("Connection: close");
        ignore_user_abort(true);
        ob_start();
        echo('text response to ajax');
        $size = ob_get_length();
        header("Content-Length: $size");
        ob_end_flush();
        flush();

        // if you're using sessions, this prevents subsequent requests
        // from hanging while the background process executes
        if (session_id()) {
            session_write_close();
        }

        /************** background process starts here **************/
```

View in this post: How do I close a connection early?

答:
You are calling the executeProgressBar instantly instead of waiting for the first AJAX call to complete. Call the executeProgressBar function in the success method callback and pass it to the executeProgressBar function and modify the parameters like the example below.

Be sure to build a check in that lets the recursive function know when to stop.

```<code>$.ajax({
    type: "POST",
    enctype: 'multipart/form-data',
    processData: false,
    contentType: false,
    cache: false,
    url: "/long_process",
    data: form_data,
    success: function (response) {
        executeProgressBar(1, token, response);
    }
});

function executeProgressBar(start, token, response) {

    if (start == 1) {

        //reset progress bar
        $('.progress-bar').css('width', '0%');
        $('.progress-bar').text('0%');
        $('.progress-bar').attr('data-progress', '0');

    }

    $.ajax({
        type: "POST",
        url: "/progress_bar_status",
        data: {token: token, sleep: 0},
        success: function (response) {

            $('.progress-bar').css('width', response['percentage'] + '%');
            $('.progress-bar').text(response['percentage'] + '%');
            $('.progress-bar').attr('data-progress', response['percentage']);

            $('#done').text(response['executed']);
            $('.execute-time').text('tiempo');

            if (response.percentage == 100) {
                $('.end-process').show();
            } else {
                executeProgressBar(0, token, response);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (textStatus == 'parsererror') {
                textStatus = 'Technical error: Unexpected response returned by server. Sending stopped.';
            }
            alert(textStatus);
        }
    });
}
</code>```

Body:
I have an ajax that call to a server and run a long process (this process is writing the status on a database).

I have other ajax (recursively) to get the status of the long process and set the params on a Progress Bar.

My problem is that the second ajax not start until the first one finishes. Is there a way to send the first ajax and no wait for a response?

Any ideas?

I appreciate any suggestion, I am a little bit tired about this issue.

If there is another method to send a long process and get the status of the long process, tell me, please.

Thank you!

This is my code, in case it's helps

executeProgressBar(1, token);

$.ajax({
  type: "POST",
  enctype: 'multipart/form-data',
  processData: false,
  contentType: false,
  cache: false,
  url: "/long_process",
  data: form_data,
  success: function (response) {
    //NOTHING
  }
});

function executeProgressBar(start, token) {

  if (start == 1) {

    //reset progress bar
    $('.progress-bar').css('width', '0%');
    $('.progress-bar').text('0%');
    $('.progress-bar').attr('data-progress', '0');

  }

  $.ajax({
    type: "POST",
    url: "/progress_bar_status",
    data: { token: token, sleep: 0 },
    success: function (response) {

      $('.progress-bar').css('width', response['percentage'] + '%');
      $('.progress-bar').text(response['percentage'] + '%');
      $('.progress-bar').attr('data-progress', response['percentage']);

      $('#done').text(response['executed']);
      $('.execute-time').text('tiempo');

      if (response.percentage == 100) {
        $('.end-process').show();
      } else {
        executeProgressBar(0, token);
      }
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      if (textStatus == 'parsererror') {
        textStatus = 'Technical error: Unexpected response returned by server. Sending stopped.';
      }
      alert(textStatus);
    }
  });
}

EDIT

I solved whit this code on the server side - php

        /************** Close connection and return echo message **************/
        ob_end_clean();
        header("Connection: close");
        ignore_user_abort(true);
        ob_start();
        echo('text response to ajax');
        $size = ob_get_length();
        header("Content-Length: $size");
        ob_end_flush();
        flush();

        // if you're using sessions, this prevents subsequent requests
        // from hanging while the background process executes
        if (session_id()) {
            session_write_close();
        }

        /************** background process starts here **************/

View in this post: How do I close a connection early?

Body:
You are calling the executeProgressBar instantly instead of waiting for the first AJAX call to complete. Call the executeProgressBar function in the success method callback and pass it to the executeProgressBar function and modify the parameters like the example below.

Be sure to build a check in that lets the recursive function know when to stop.

$.ajax({
    type: "POST",
    enctype: 'multipart/form-data',
    processData: false,
    contentType: false,
    cache: false,
    url: "/long_process",
    data: form_data,
    success: function (response) {
        executeProgressBar(1, token, response);
    }
});

function executeProgressBar(start, token, response) {

    if (start == 1) {

        //reset progress bar
        $('.progress-bar').css('width', '0%');
        $('.progress-bar').text('0%');
        $('.progress-bar').attr('data-progress', '0');

    }

    $.ajax({
        type: "POST",
        url: "/progress_bar_status",
        data: {token: token, sleep: 0},
        success: function (response) {

            $('.progress-bar').css('width', response['percentage'] + '%');
            $('.progress-bar').text(response['percentage'] + '%');
            $('.progress-bar').attr('data-progress', response['percentage']);

            $('#done').text(response['executed']);
            $('.execute-time').text('tiempo');

            if (response.percentage == 100) {
                $('.end-process').show();
            } else {
                executeProgressBar(0, token, response);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (textStatus == 'parsererror') {
                textStatus = 'Technical error: Unexpected response returned by server. Sending stopped.';
            }
            alert(textStatus);
        }
    });
}


问:
Mongodb specifying type "string" returns "array" fields as well
As you can test here, specifying {"key": {$type: "string"}} returns documents that have key field in type of array that contain strings in them.

In the example, I expected that the query should have returned only {"key": "b"}. How can get keys that only in type of string? I couldn't find in the docs.

答:
Documentation explains:

For documents where field is an array, $type returns documents in which at least one array element matches a type passed to $type.


问:
Using Fetch First with Case Expression
DB2 UDB v11.x.

Is it possible to use FETCH FIRST in an UPDATE query that uses CASE?  I sort of understand why it doesnt work but was wondering if there was a way.  for instance:

```<code>db2 "UPDATE mytable SET cstate = CASE WHEN cstate = 801 THEN cstate = 1 AND rstate = 1 WHEN cstate = 804 THEN cstate = 4 AND rstate = 4 END FETCH FIRST 20000 ROWS ONLY"
</code>```

This results in only one row being changed at a time.

Tried:

```<code>db2 "UPDATE mytable SET cstate = CASE WHEN cstate = (SELECT cstate FROM mytable WHERE cstate = 801 FETCH FIRST 20000 ROWS ONLY) THEN cstate = 1 AND rstate = 1 WHEN cstate = (SELECT cstate FROM mytable WHERE cstate = 804 FETCH FIRST 20000 ROWS ONLY) THEN cstate = 4 AND rstate = 4 END"
</code>```

This gets:

```<code>SQL0811N  The result of a scalar fullselect, SELECT INTO statement, or VALUES
INTO statement is more than one row
</code>```

Any way to do this? Was hoping not to split it up and reiterating through the table twice (or having to do one update at a time).

答:
This would be the simplest method

```<code>UPDATE
(   SELECT * FROM
    (   SELECT
            cstate
        ,   rstate
        ,   CASE WHEN cstate = 801 THEN 1 WHEN cstate = 804 THEN 4 ELSE cstate END new_cstate
        ,   CASE WHEN cstate = 801 THEN 1 WHEN cstate = 804 THEN 4 ELSE rstate END new_rstate
        FROM
            mytable
    )
    WHERE
        cstate IS DISTINCT FROM new_cstate
    OR  rstate IS DISTINCT FROM new_rstate
    FETCH FIRST 20000 ROWS ONLY
)
SET cstate = new_cstate
,   rstate = new_rstate
</code>```

just keep running it until it updates no rows.

Title: Using Fetch First with Case Expression

Body:
DB2 UDB v11.x.

Is it possible to use FETCH FIRST in an UPDATE query that uses CASE?  I sort of understand why it doesnt work but was wondering if there was a way.  for instance:

db2 "UPDATE mytable SET cstate = CASE WHEN cstate = 801 THEN cstate = 1 AND rstate = 1 WHEN cstate = 804 THEN cstate = 4 AND rstate = 4 END FETCH FIRST 20000 ROWS ONLY"

This results in only one row being changed at a time.

Tried:

db2 "UPDATE mytable SET cstate = CASE WHEN cstate = (SELECT cstate FROM mytable WHERE cstate = 801 FETCH FIRST 20000 ROWS ONLY) THEN cstate = 1 AND rstate = 1 WHEN cstate = (SELECT cstate FROM mytable WHERE cstate = 804 FETCH FIRST 20000 ROWS ONLY) THEN cstate = 4 AND rstate = 4 END"

This gets:

SQL0811N  The result of a scalar fullselect, SELECT INTO statement, or VALUES
INTO statement is more than one row

Any way to do this? Was hoping not to split it up and reiterating through the table twice (or having to do one update at a time).

Body:
This would be the simplest method

UPDATE
(   SELECT * FROM
    (   SELECT
            cstate
        ,   rstate
        ,   CASE WHEN cstate = 801 THEN 1 WHEN cstate = 804 THEN 4 ELSE cstate END new_cstate
        ,   CASE WHEN cstate = 801 THEN 1 WHEN cstate = 804 THEN 4 ELSE rstate END new_rstate
        FROM
            mytable
    )
    WHERE
        cstate IS DISTINCT FROM new_cstate
    OR  rstate IS DISTINCT FROM new_rstate
    FETCH FIRST 20000 ROWS ONLY
)
SET cstate = new_cstate
,   rstate = new_rstate

just keep running it until it updates no rows.


问:
Understanding `scale` in R
I'm trying to understand the definition of scale that R provides. I have data (mydata) that I want to make a heat map with, and there is a VERY strong positive skew. I've created a heatmap with a dendrogram for both scale(mydata) and log(my data), and the dendrograms are different for both. Why? What does it mean to scale my data, versus log transform my data? And which would be more appropriate if I want to look at the dendrogram illustrating the relationship between the columns of my data?

Thank you for any help! I've read the definitions but they are whooping over my head.

答:
I thought I would contribute by providing a concrete example of the practical use of the scale function. Say you have 3 test scores (Math, Science, and English) that you want to compare. Maybe you may even want to generate a composite score based on each of the 3 tests for each observation. Your data could look as as thus:

```<code>student_id <- seq(1,10)
math <- c(502,600,412,358,495,512,410,625,573,522)
science <- c(95,99,80,82,75,85,80,95,89,86)
english <- c(25,22,18,15,20,28,15,30,27,18)
df <- data.frame(student_id,math,science,english)
</code>```

Obviously it would not make sense to compare the means of these 3 scores as the scale of the scores are vastly different. By scaling them however, you have more comparable scoring units:

```<code>z <- scale(df[,2:4],center=TRUE,scale=TRUE)
</code>```

You could then use these scaled results to create a composite score. For instance, average the values and assign a grade based on the percentiles of this average. Hope this helped!

Note: I borrowed this example from the book "R In Action". It's a great book! Would definitely recommend.

ContentLicense: CC BY-SA 3.0

Title: Understanding `scale` in R

Body:
I thought I would contribute by providing a concrete example of the practical use of the scale function. Say you have 3 test scores (Math, Science, and English) that you want to compare. Maybe you may even want to generate a composite score based on each of the 3 tests for each observation. Your data could look as as thus:

student_id <- seq(1,10)
math <- c(502,600,412,358,495,512,410,625,573,522)
science <- c(95,99,80,82,75,85,80,95,89,86)
english <- c(25,22,18,15,20,28,15,30,27,18)
df <- data.frame(student_id,math,science,english)

Obviously it would not make sense to compare the means of these 3 scores as the scale of the scores are vastly different. By scaling them however, you have more comparable scoring units:

z <- scale(df[,2:4],center=TRUE,scale=TRUE)

You could then use these scaled results to create a composite score. For instance, average the values and assign a grade based on the percentiles of this average. Hope this helped!

Note: I borrowed this example from the book "R In Action". It's a great book! Would definitely recommend.


问:
HTML not loading CSS file
I am completely stumped as to why this doesn't work. It seems the HTML file can't load the CSS for some reason, even though both are in the same directory. Any idea what might be the problem?

index.html

```<code><!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" href="style.css" media="screen" />
<meta name="viewport" content="width=1100">
</head>
<body>
<div id="main"> Hello </div>
</body>
</html>
</code>```

style.css

```<code>body{
    background-color: #F9F9F9;
    background-image: url(images/bg3.png);
    background-position: center top;
    background-repeat: repeat;
    text-shadow: #FFFFFF 0px 1px 0px;
    font-family: "Georgia", "Times", serif;
    -webkit-font-smoothing: antialiased;
}

a{
    text-decoration: none;
}

#main{
    margin: 50px auto 50px auto;
    width: 1000px;
    min-height: 500px;
    padding: 0px 20px 0px 20px;
}
</code>```

The above doesn't work. Adding the css inline in index.html works fine though

```<code><!DOCTYPE html>
<html>
<head>
<title>Homepage</title>
<style type="text/css" media="screen">
    body {
        background-color: #F9F9F9;
        background-image: url(images/bg3.png);
        background-position: center top;
        background-repeat: repeat;
        text-shadow: #FFFFFF 0px 1px 0px;
        font-family: "Georgia", "Times", serif;
        -webkit-font-smoothing: antialiased;
    }
    a {
        text-decoration: none;
    }
    #main {
        margin: 50px auto 50px auto;
        width: 1000px;
        min-height: 500px;
        padding: 0px 20px 0px 20px;
    }
</style>
<meta name="viewport" content="width=1100">
</head>
<body>
    <div id="main"> Hello </div>
</body>
</html>
</code>```

答:
i have the same probleme, i always change the "style.css" to "styles.css" or any other name
and it worked fine for me.</p>

Title: HTML not loading CSS file

Body:
I am completely stumped as to why this doesn't work. It seems the HTML file can't load the CSS for some reason, even though both are in the same directory. Any idea what might be the problem?

index.html

<!DOCTYPE html>

<title>Home Page</title>
<link rel="stylesheet" href="style.css" media="screen" />
<meta name="viewport" content="width=1100">

 Hello

style.css

body{
    background-color: #F9F9F9;
    background-image: url(images/bg3.png);
    background-position: center top;
    background-repeat: repeat;
    text-shadow: #FFFFFF 0px 1px 0px;
    font-family: "Georgia", "Times", serif;
    -webkit-font-smoothing: antialiased;
}

a{
    text-decoration: none;
}

#main{
    margin: 50px auto 50px auto;
    width: 1000px;
    min-height: 500px;
    padding: 0px 20px 0px 20px;
}

The above doesn't work. Adding the css inline in index.html works fine though

<!DOCTYPE html>

<title>Homepage</title>

<meta name="viewport" content="width=1100">

 Hello


问:
Odd Syntax (Walrus operator in inheritance)
I was looking in python's grammar and was that you could use the walrus operator in inheritance! Not believing it, I tried it out:

```<code>class foo: pass
class bar(foobar := foo):
    def x(self):
        print("it works!")

b = bar()
b.x()
</code>```

This does not raise any syntax error (python 3.8.2)! What is the use of it, and how does it work?

答:
What is the use of it, and how does it work?

There is no specific use case for the walrus operator in inheritance. It works simply because the class is an expression, so it allows everything an expression allows, including the walrus operator. As pointed out in the comments, you could achieve the same result using:

```<code>foobar = foo
class bar(foobar):
    ...
</code>```

Other things allowed in expressions would work just as well, such as parentheses and function calls:

```<code>class bar(((foo))):
    pass

class bar((lambda x: x)(foo)):
    pass
</code>```

Body:
I was looking in python's grammar and was that you could use the walrus operator in inheritance! Not believing it, I tried it out:

class foo: pass
class bar(foobar := foo):
    def x(self):
        print("it works!")

b = bar()
b.x()

This does not raise any syntax error (python 3.8.2)! What is the use of it, and how does it work?

Body:
What is the use of it, and how does it work?

There is no specific use case for the walrus operator in inheritance. It works simply because the class is an expression, so it allows everything an expression allows, including the walrus operator. As pointed out in the comments, you could achieve the same result using:

foobar = foo
class bar(foobar):
    ...

Other things allowed in expressions would work just as well, such as parentheses and function calls:

class bar(((foo))):
    pass

class bar((lambda x: x)(foo)):
    pass


问:
How to add vertical differential lines (or residuals) in matplotlib?
I want to add vertical lines that depict the residuals of y1_predict - y_true and y2_predict - y_true, with red and blue color dash lines, respectively. I would prefer to add lines on top of the current graph, and the code that I can write is shown bellow. Please ignore my code if plotting from scratch is necessary.

```<code>import matplotlib.pyplot as plt

x = x_data
ys = [y_true,y1_predict,y2_predict]
labels = ['EMT', 'NN 1st round', 'NN 2nd round']
markers = ['o','s','D']
colors = ['k','r','b']
alphas = [1, 1, 1]
linestyles = ['None','None','None']
fillstyles = ['full','none','none']
plt.figure(figsize=(8, 6), dpi=100, facecolor='w', edgecolor='k')
plt.xlabel("Structure", fontsize=12)
plt.ylabel("Relaxed energy per atom / eV", fontsize=12)
plt.title("NN vs. EMT (low energy region)")
for y, label, marker, color, alpha, linestyle, fillstyle in zip(ys, labels, markers, colors, alphas, linestyles, fillstyles):
    plt.plot(x,y, label=label, marker=marker, color=color, alpha=alpha, linestyle=linestyle, fillstyle=fillstyle)

plt.ylim([0.21, 0.25])
plt.legend(loc="lower left",prop={'size': 14})
plt.savefig('nn-emt.png')
</code>```

答:
Just add the following two lines to your code. This will plot multiple vertical lines at all the points. Since your question is poorly asked, missing a reproducible code, I cannot test it myself.</p>

```<code>plt.vlines(x, y1_predict, y_true, color='r')
plt.vlines(x, y2_predict, y_true, color='b')
</code>```

Body:
I want to add vertical lines that depict the residuals of y1_predict - y_true and y2_predict - y_true, with red and blue color dash lines, respectively. I would prefer to add lines on top of the current graph, and the code that I can write is shown bellow. Please ignore my code if plotting from scratch is necessary.

import matplotlib.pyplot as plt

x = x_data
ys = [y_true,y1_predict,y2_predict]
labels = ['EMT', 'NN 1st round', 'NN 2nd round']
markers = ['o','s','D']
colors = ['k','r','b']
alphas = [1, 1, 1]
linestyles = ['None','None','None']
fillstyles = ['full','none','none']
plt.figure(figsize=(8, 6), dpi=100, facecolor='w', edgecolor='k')
plt.xlabel("Structure", fontsize=12)
plt.ylabel("Relaxed energy per atom / eV", fontsize=12)
plt.title("NN vs. EMT (low energy region)")
for y, label, marker, color, alpha, linestyle, fillstyle in zip(ys, labels, markers, colors, alphas, linestyles, fillstyles):
    plt.plot(x,y, label=label, marker=marker, color=color, alpha=alpha, linestyle=linestyle, fillstyle=fillstyle)

plt.ylim([0.21, 0.25])
plt.legend(loc="lower left",prop={'size': 14})
plt.savefig('nn-emt.png')

Body:
Just add the following two lines to your code. This will plot multiple vertical lines at all the points. Since your question is poorly asked, missing a reproducible code, I cannot test it myself.

plt.vlines(x, y1_predict, y_true, color='r')
plt.vlines(x, y2_predict, y_true, color='b')


问:
Wrong use of GROUP BY
i'm having a real problem with a query. The database entity are:

```<code>Paziente (Codice_Fiscale, Nome_Paziente, Cognome_Paziente, Data_Nascita, Luogo_Nascita)
Appuntamento (Codice_Appuntamento, Data_Appuntamento, Ora_Appuntamento, Codice_Fiscale)
Intervento (Codice_Intervento, Tipo_Intervento, Sala_Intervento, Data_Intervento, Ora_Intervento, Codice_Fiscale_Paziente, ID_Dentista)
Dentista (ID_Dentista, Nome_Dentista, Cognome_Dentista)
</code>```

I need to do a query that shows a list of appointment grouped by type of intervention.
It should be something like:

```<code>Tipo_Intervento       COUNT(*)
Chirurgia dentale      1
Cura carie             2
Estrazione dentale     1
Pulizia dentale        3
</code>```

I can do this correctly when i use this query:

```<code>SELECT intervento.Tipo_Intervento, COUNT(*)
FROM intervento
GROUP BY intervento.Tipo_Intervento
</code>```

But i need to link the database "intervento" to "appuntamento" ('cause it's an exercise) and when i use this:

```<code>SELECT COUNT(DISTINCT appuntamento.Codice_Appuntamento) AS Numero_Appuntamenti, intervento.Tipo_Intervento AS Tipologia_intervento
FROM appuntamento, intervento
WHERE appuntamento.Codice_Fiscale = intervento.Codice_Fiscale_Paziente
GROUP BY intervento.Tipo_Intervento
</code>```

I obtain the wrong value:

```<code>Numero_Appuntamenti      Tipologia_intervento
2                        Chirurgia dentale
4                        Cura carie
2                        Estrazione dentale
3                        Pulizia dentale
</code>```

The problem is in the GROUP BY intervento.Tipo_Intervento, that increase the number of appointments, in fact if i use GROUP BY appuntamento.Codice_Appuntamento i obtain:

```<code>Numero_Appuntamenti  Tipologia_intervento
1                    Pulizia dentale
1                    Estrazione dentale
1                    Pulizia dentale
1                    Cura carie
1                    Cura carie
1                    Pulizia dentale
1                    Estrazione dentale
</code>```

That is right, but i need it to be grouped.

Does someone can help me? (forgive my bad english, as you can see it's not my language)

EDIT: This is the table "appuntamento":

```<code>Codice_Appuntamento Data_Appuntamento   Ora_Appuntamento    Codice_Fiscale
        001           2020-05-05    16:00:00.000000     RSSMRA80A01H501U
        002           2020-07-03    16:30:00.000000     VRDGPP85E02F205P
        003          2020-06-05     16:00:00.000000     RSSMRA80A01H501U
        004          2020-08-14     17:15:00.000000     BNCGNN83D03L219B
        005           2020-08-27    17:45:00.000000     BNCGNN83D03L219B
        006          2020-07-05     16:00:00.000000     RSSMRA80A01H501U
        007          2020-09-13     17:20:00.000000     VRDGPP85E02F205P
</code>```

And this the table "intervento"

```<code>Codice_Intervento Tipo_Intervento   Sala_Intervento    Data_Intervento   Ora_Intervento   Codice_Fiscale_Paziente   ID_Dentista
    A_001          Pulizia dentale        1             2020-05-05       16:00:00.000000    RSSMRA80A01H501U            D_001
    A_002          Estrazione dentale     2             2020-07-03        16:30:00.000000   VRDGPP85E02F205P            D_003
    A_003          Pulizia dentale        1             2020-06-05        16:00:00.000000   RSSMRA80A01H501U            D_001
    A_004          Cura carie             3             2020-08-14        17:15:00.000000   BNCGNN83D03L219B            D_001
    A_005          Chirurgia dentale      5             2020-08-27        17:45:00.000000   BNCGNN83D03L219B            D_002
    A_006          Pulizia dentale        1             2020-07-05        16:00:00.000000   RSSMRA80A01H501U            D_001
    A_007          Cura carie             3             2020-09-13         17:20:00.000000  VRDGPP85E02F205P            D_002
</code>```

"Codice fiscale" and "ID_Dentista" are the foreing key, thery are the primary key of "paziente" and "dentista"

答:
You can use this query:</p>

```<code>SELECT max(i.Tipo_Intervento), count(a. Codice_Appuntamento)
FROM intervento as i left join appuntamento as a on i.Codice_Fiscale_Paziente = a.Codice_Fiscale
GROUP BY i.Sala_Intervento
</code>```

Title: Wrong use of GROUP BY

Body:
i'm having a real problem with a query. The database entity are:

Paziente (Codice_Fiscale, Nome_Paziente, Cognome_Paziente, Data_Nascita, Luogo_Nascita)
Appuntamento (Codice_Appuntamento, Data_Appuntamento, Ora_Appuntamento, Codice_Fiscale)
Intervento (Codice_Intervento, Tipo_Intervento, Sala_Intervento, Data_Intervento, Ora_Intervento, Codice_Fiscale_Paziente, ID_Dentista)
Dentista (ID_Dentista, Nome_Dentista, Cognome_Dentista)

I need to do a query that shows a list of appointment grouped by type of intervention.
It should be something like:

Tipo_Intervento       COUNT(*)
Chirurgia dentale      1
Cura carie             2
Estrazione dentale     1
Pulizia dentale        3

I can do this correctly when i use this query:

SELECT intervento.Tipo_Intervento, COUNT(*)
FROM intervento
GROUP BY intervento.Tipo_Intervento

But i need to link the database "intervento" to "appuntamento" ('cause it's an exercise) and when i use this:

SELECT COUNT(DISTINCT appuntamento.Codice_Appuntamento) AS Numero_Appuntamenti, intervento.Tipo_Intervento AS Tipologia_intervento
FROM appuntamento, intervento
WHERE appuntamento.Codice_Fiscale = intervento.Codice_Fiscale_Paziente
GROUP BY intervento.Tipo_Intervento

I obtain the wrong value:

Numero_Appuntamenti      Tipologia_intervento
2                        Chirurgia dentale
4                        Cura carie
2                        Estrazione dentale
3                        Pulizia dentale

The problem is in the GROUP BY intervento.Tipo_Intervento, that increase the number of appointments, in fact if i use GROUP BY appuntamento.Codice_Appuntamento i obtain:

Numero_Appuntamenti  Tipologia_intervento
1                    Pulizia dentale
1                    Estrazione dentale
1                    Pulizia dentale
1                    Cura carie
1                    Cura carie
1                    Pulizia dentale
1                    Estrazione dentale

That is right, but i need it to be grouped.

Does someone can help me? (forgive my bad english, as you can see it's not my language)

EDIT: This is the table "appuntamento":

Codice_Appuntamento Data_Appuntamento   Ora_Appuntamento    Codice_Fiscale
        001           2020-05-05    16:00:00.000000     RSSMRA80A01H501U
        002           2020-07-03    16:30:00.000000     VRDGPP85E02F205P
        003          2020-06-05     16:00:00.000000     RSSMRA80A01H501U
        004          2020-08-14     17:15:00.000000     BNCGNN83D03L219B
        005           2020-08-27    17:45:00.000000     BNCGNN83D03L219B
        006          2020-07-05     16:00:00.000000     RSSMRA80A01H501U
        007          2020-09-13     17:20:00.000000     VRDGPP85E02F205P

And this the table "intervento"

Codice_Intervento Tipo_Intervento   Sala_Intervento    Data_Intervento   Ora_Intervento   Codice_Fiscale_Paziente   ID_Dentista
    A_001          Pulizia dentale        1             2020-05-05       16:00:00.000000    RSSMRA80A01H501U            D_001
    A_002          Estrazione dentale     2             2020-07-03        16:30:00.000000   VRDGPP85E02F205P            D_003
    A_003          Pulizia dentale        1             2020-06-05        16:00:00.000000   RSSMRA80A01H501U            D_001
    A_004          Cura carie             3             2020-08-14        17:15:00.000000   BNCGNN83D03L219B            D_001
    A_005          Chirurgia dentale      5             2020-08-27        17:45:00.000000   BNCGNN83D03L219B            D_002
    A_006          Pulizia dentale        1             2020-07-05        16:00:00.000000   RSSMRA80A01H501U            D_001
    A_007          Cura carie             3             2020-09-13         17:20:00.000000  VRDGPP85E02F205P            D_002

"Codice fiscale" and "ID_Dentista" are the foreing key, thery are the primary key of "paziente" and "dentista"

Body:
You can use this query:

SELECT max(i.Tipo_Intervento), count(a. Codice_Appuntamento)
FROM intervento as i left join appuntamento as a on i.Codice_Fiscale_Paziente = a.Codice_Fiscale
GROUP BY i.Sala_Intervento


问:
cl x64: unsigned long outside / inside union: error C2099: initializer is not a constant / NO error
Case 1. File: test1.c:

```<code>unsigned long val = (unsigned long)&"test";

int main()
{
    return 0;
}
</code>```

Compiler invocation: cl test1.c /c

Results:

```<code>Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28611 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test1.c
test1.c(1): warning C4311: 'type cast': pointer truncation from 'char (*)[5]' to 'unsigned long'
test1.c(1): error C2099: initializer is not a constant
</code>```

Case 2. File: test2.c:

```<code>union { unsigned long val; } val =  { (unsigned long)&"test" };

int main()
{
    return 0;
}
</code>```

Compiler invocation: cl test2.c /c

Results:

```<code>Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28611 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test2.c
test2.c(1): warning C4311: 'type cast': pointer truncation from 'char (*)[5]' to 'unsigned long'
</code>```

Question: why after putting unsigned long into union (case 2, file test2.c) the error C2099: initializer is not a constant is gone?

Notes:

for both code versions cl x86 (same version as for x64) produces NO errors, NO warnings.

for both code versions gcc x86/x64 (version 9.3.0) produces NO errors, NO warnings.

UPD. Please note: the question is not about safe code / unsafe code or wrong code / right code. The question is about cl compiler behavior. I.e. why in the 2nd case the cl considers that initializer IS a constant (such conclusion is from the absence of the error message).

答:
Initializers for objects of static storage duration must be constant expressions .

In the C89 standard (the only standard to which Microsoft C conforms) , a cast from pointer to integer is not permitted in a constant expression.

This is a Semantic rule and not a Constraint, which means the program has undefined behaviour with no diagnostic required. Therefore the compiler is permitted to reject the program (but is not required to reject it), it may or may not issue diagnostics, and there is no requirement of consistency amongst various programs that are undefined.

We cannot conclude from the absence of an Error message that the initializer was accepted as a constant .

Since C99, the standard also includes the text "An implementation may accept other forms of constant expressions". The compiler should publish conformance documentation listing which expressions it accepts as constants, although I couldn't find that documentation for MSVC. (leave a comment if you can!)

It may also be relevant to note the rules about casting pointer to unsigned long. From the latest Standard:

Any pointer type may be converted to an integer type. Except as previously specified, the
  result is implementation-defined. If the result cannot be represented in the integer type,
  the behavior is undefined. The result need not be in the range of values of any integer
  type.

So, even if the C99 or C11-compliant compiler documents that it accepts casts from pointer to integer in constant expressions, it may still be that the result of the cast causes a trap on startup, or causes undefined behaviour (which , as before, means no diagnostic is required and the program may be rejected).

Body:
Case 1. File: test1.c:

unsigned long val = (unsigned long)&"test";

int main()
{
    return 0;
}

Compiler invocation: cl test1.c /c

Results:

Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28611 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test1.c
test1.c(1): warning C4311: 'type cast': pointer truncation from 'char (*)[5]' to 'unsigned long'
test1.c(1): error C2099: initializer is not a constant

Case 2. File: test2.c:

union { unsigned long val; } val =  { (unsigned long)&"test" };

int main()
{
    return 0;
}

Compiler invocation: cl test2.c /c

Results:

Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28611 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test2.c
test2.c(1): warning C4311: 'type cast': pointer truncation from 'char (*)[5]' to 'unsigned long'

Question: why after putting unsigned long into union (case 2, file test2.c) the error C2099: initializer is not a constant is gone?

Notes:

for both code versions cl x86 (same version as for x64) produces NO errors, NO warnings.

for both code versions gcc x86/x64 (version 9.3.0) produces NO errors, NO warnings.

UPD. Please note: the question is not about safe code / unsafe code or wrong code / right code. The question is about cl compiler behavior. I.e. why in the 2nd case the cl considers that initializer IS a constant (such conclusion is from the absence of the error message).


问:
Add a web User to SQL without using ASP.NET Configuration button in Visual Studio
Hello how can I add users and give them roles without using the ASP.NET Configuration button in Visual Studio

I wrote a web site that requires a login.

I am not using SQL express to hold user information
I ran aspnet_regsql and configured some users using the ASP.NET Configuration button.
I uploaded the database to the server and no I need to add a user.

By boss is in a meeting with the client at this very moment so this is failry urgent.

I hope an pray that I have explained what I want well enough to get some help.

There must be a way of going to the server database and adding a user.
Many thanks

答:
This is all in the Membership Provider and can be controlled programatically. The best place to start is look at a complete overview, as it will help you better understand how to do this. As an example: https://web.archive.org/web/20211020202857/http://www.4guysfromrolla.com/articles/120705-1.aspx

Do not try to do this using SQL Queries alone, unless you have configured the membership provider to use no encryption. If you try to circumvent, which is possible in some instances, you will mess things up. In the standard Membership Provider, you have methods to create users and put them in roles. It is a bit kludgy and I have personally customized a bit to make things easier, but the standard classes are not that unwieldy with creation of users and putting them in roles (big issue was changing without a customized membership provider).


问:
Flutter Firebase - DropdownMenuItem: The method 'map' was called on null
In my application I would like to display vaccines according to the species of the animal (If is a dog or cat). I'm experiencing an error: The method 'map' was called on null. Tried calling: map DropdownMenuItem. Why is this happening? I already put async and await in the methods, I don't understand why it is still null. Bellow my code:

1) This is where I call my DropdownContent class in init to prepare my DropdownMenuItem in the row inside the widget

```<code>class _VaccineDetailFormState extends State<VaccineDetailForm> {

final DataRepository repository = DataRepository();
String selectedVaccine = "Select";
List<String> vaccinesBySpecie;

  initState() {
    DropdownContent.getVaccines(widget.selectedPetID).then((value) => vaccinesBySpecie = value);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
    [...]
              new Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    new DropdownButton<String>(
                      value:  widget.vaccine.name == null ? selectedVaccine: widget.vaccine.name,
                      underline: Container(
                        height: 2,
                        color: Colors.grey,
                      ),
                      onChanged: (String newValue) {
                        setState(() {
                          selectedVaccine = newValue;
                          widget.vaccine.name = newValue;
                        });
                      },
                      items: vaccinesBySpecie.map<DropdownMenuItem<String>>((String value) {
                        return DropdownMenuItem<String>(
                          value: value,
                          child: Text(value),
                        );
                      }).toList(),
                    )
                  ]),

                  [...]
</code>```

2) Here is the DropdownContent class that, inside the getVaccines() method, searches the repository to find out the species of the current animal and then returns the appropriate vaccine list.

```<code>class Dropdown content

static Future<List<String>> getVaccines(String petId) async {

    final DataRepository repository = DataRepository();
    String currentSpecie = await repository.getSpecie(petId);

    if (currentSpecie.contains('Dog')) {
      return listOfVaccinesForDogs();
    }
    if (currentSpecie.contains('Cat')) {
      return listOfVaccinesForCats();
    }
}
</code>```

3) Finally, the repository class that searches for the species of the animal

```<code> class Repository

   Future<String> getSpecie(String petId) async {
    DocumentReference documentReference = petCollection.document(petId);
    await documentReference.get().then((snapshot) {
      return snapshot.data['specie'].toString();
    });
  }
</code>```

答:
While your initState method may be asynchronous, your build method isn't. So at the time that the build method is called, your vaccinesBySpecie method is null.
The best way to fix this would be to initialize your List<String> vaccinesBySpecie like so List<String> vaccinesBySpecie = [];. This way it isn't null when the build method is called.

As a side note, I would suggest using a FutureBuilder or StreamBuilder if you can, that way you can handle when there isn't a value (i.e it is null) vs when there is a value(ie it is not null)

Body:
In my application I would like to display vaccines according to the species of the animal (If is a dog or cat). I'm experiencing an error: The method 'map' was called on null. Tried calling: map DropdownMenuItem. Why is this happening? I already put async and await in the methods, I don't understand why it is still null. Bellow my code:

1) This is where I call my DropdownContent class in init to prepare my DropdownMenuItem in the row inside the widget

class _VaccineDetailFormState extends State<VaccineDetailForm> {

final DataRepository repository = DataRepository();
String selectedVaccine = "Select";
List<String> vaccinesBySpecie;

  initState() {
    DropdownContent.getVaccines(widget.selectedPetID).then((value) => vaccinesBySpecie = value);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
    [...]
              new Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    new DropdownButton<String>(
                      value:  widget.vaccine.name == null ? selectedVaccine: widget.vaccine.name,
                      underline: Container(
                        height: 2,
                        color: Colors.grey,
                      ),
                      onChanged: (String newValue) {
                        setState(() {
                          selectedVaccine = newValue;
                          widget.vaccine.name = newValue;
                        });
                      },
                      items: vaccinesBySpecie.map<DropdownMenuItem<String>>((String value) {
                        return DropdownMenuItem<String>(
                          value: value,
                          child: Text(value),
                        );
                      }).toList(),
                    )
                  ]),

                  [...]

2) Here is the DropdownContent class that, inside the getVaccines() method, searches the repository to find out the species of the current animal and then returns the appropriate vaccine list.

class Dropdown content

static Future<List<String>> getVaccines(String petId) async {

    final DataRepository repository = DataRepository();
    String currentSpecie = await repository.getSpecie(petId);

    if (currentSpecie.contains('Dog')) {
      return listOfVaccinesForDogs();
    }
    if (currentSpecie.contains('Cat')) {
      return listOfVaccinesForCats();
    }
}

3) Finally, the repository class that searches for the species of the animal

 class Repository

   Future<String> getSpecie(String petId) async {
    DocumentReference documentReference = petCollection.document(petId);
    await documentReference.get().then((snapshot) {
      return snapshot.data['specie'].toString();
    });
  }


问:
An unhandled exception occurred: error TS5024: Compiler option 'sourceMap' requires a value of type boolean
I am updating my angular code version from 4.0.0 to latest. Instead of updating it all together from version 4.0.0 to 9.1.2, as a recommendation I tried doing it to version 6.0.0 first and then to 8.0.0 and finally to version 9.1.2. But while doing so following this link I first tried doing it to version 6.0.0. But somehow it updated packages to latest versions directly.
Now while running the command 'npm start' I am facing following issue :

An unhandled exception occurred: error TS5024: Compiler option 'sourceMap' requires a value of type boolean.

and following error for ng serve command :

Schema validation failed with the following errors:
  Data path "" should have required property 'browserTarget'.

angular.json

```<code>{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "sitc-web-app": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ],
            "styles": [
              "src/assets/SHUI/shui-styles.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/bundle.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/polyfills.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/vendors.min.js",
              "src/assets/SHUI/shui.min.js"
            ]
          },
          "configurations": {
            "local": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.ts"
                }
              ]
            },
            "dev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.dev.ts"
                }
              ]
            },
            "staging": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.staging.ts"
                }
              ]
            },
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "local": {
              "browserTarget": "sitc-web-app:build"
            },
            "dev": {
              "browserTarget": "sitc-web-app:build:dev"
            },
            "staging": {
              "browserTarget": "sitc-web-app:build:staging"
            },
            "production": {
              "browserTarget": "sitc-web-app:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "sitc-web-app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/bundle.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/polyfills.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/vendors.min.js",
              "src/assets/SHUI/shui.min.js"
            ],
            "styles": [
              "src/assets/SHUI/shui-styles.css",
              "src/styles.css"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "sitc-web-app-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "sitc-web-app:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "sitc-web-app",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}
</code>```

I separately added the 'local' part inside 'serve->configurations' and 'configurations' as I am running my code in local environment also.

package.json

```<code>{
  "name": "abc-web-app",
  "version": "0.0.0",
  "license": "XYZ",
  "scripts": {
    "ng": "ng",
    "start": "ng serve -o --configuration=local",
    "build-dev": "ng build --prod --configuration=dev --output-path=dist/dev",
    "build-staging": "ng build --prod --configuration=staging --output-path=dist/staging",
    "build-prod": "ng build --prod --configuration=prod --output-path=dist/prod",
    "build": "npm-run-all -p build-dev build-staging build-prod",
    "local-build-dev": "npm run build-dev && deleteAndCopy.bat dev",
    "local-build-staging": "npm run build-staging && deleteAndCopy.bat staging",
    "local-build-prod": "npm run build-prod && deleteAndCopy.bat prod",
    "local-build-all": "npm run local-build-dev && npm run local-build-staging && npm run local-build-prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.9",
    "@angular/common": "^9.1.9",
    "@angular/compiler": "^9.1.9",
    "@angular/core": "^9.1.9",
    "@angular/forms": "^9.1.9",
    "@angular/http": "^7.2.16",
    "@angular/platform-browser": "^9.1.9",
    "@angular/platform-browser-dynamic": "^9.1.9",
    "@angular/router": "^9.1.9",
    "angular2-csv": "^0.2.9",
    "auth0-js": "^9.13.2",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.6.5",
    "font-awesome": "^4.7.0",
    "jquery": "^3.5.1",
    "jquery-datetimepicker": "^2.5.21",
    "jwt-decode": "^2.2.0",
    "rxjs": "^6.5.5",
    "web-animations-js": "^2.3.2",
    "xml2js": "^0.4.23",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular/cli": "9.1.7",
    "@angular/compiler-cli": "^9.1.9",
    "@types/auth0-js": "^9.13.1",
    "@types/jasmine": "~3.5.10",
    "@types/jasminewd2": "~2.0.8",
    "@types/jquery": "^3.3.38",
    "@types/jwt-decode": "^2.2.1",
    "@types/node": "~14.0.6",
    "codelyzer": "^5.2.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.2",
    "karma": "~5.0.9",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "~3.3.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "npm-run-all": "^4.1.5",
    "protractor": "~7.0.0",
    "ts-node": "~8.10.2",
    "tslint": "~6.1.2",
    "typescript": "3.9.3",
    "@angular-devkit/build-angular": "~0.901.7"
  }
}
</code>```

tsconfig.json

```<code>{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "baseUrl": "src",
    "paths": {
      "@abc/models/*": ["app/models/*", "app/modules/booking-portal/models/*", "app/modules/training-portal/models/*"],
      "@abc/constants": ["app/constants"]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "preserveWhitespaces": false
  }
}
</code>```

Kindly help. Any help towards a solution regarding this is highly appreciated.
Thanks in advance.

答:
Solved it.
In tsconfig.app.json file looked like :-

```<code>{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "sourceMap": "true",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
</code>```

updated souceMap value to true instead of "true".

Body:
I am updating my angular code version from 4.0.0 to latest. Instead of updating it all together from version 4.0.0 to 9.1.2, as a recommendation I tried doing it to version 6.0.0 first and then to 8.0.0 and finally to version 9.1.2. But while doing so following this link I first tried doing it to version 6.0.0. But somehow it updated packages to latest versions directly.
Now while running the command 'npm start' I am facing following issue :

An unhandled exception occurred: error TS5024: Compiler option 'sourceMap' requires a value of type boolean.

and following error for ng serve command :

Schema validation failed with the following errors:
  Data path "" should have required property 'browserTarget'.

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "sitc-web-app": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ],
            "styles": [
              "src/assets/SHUI/shui-styles.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/bundle.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/polyfills.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/vendors.min.js",
              "src/assets/SHUI/shui.min.js"
            ]
          },
          "configurations": {
            "local": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.ts"
                }
              ]
            },
            "dev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.dev.ts"
                }
              ]
            },
            "staging": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.staging.ts"
                }
              ]
            },
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "local": {
              "browserTarget": "sitc-web-app:build"
            },
            "dev": {
              "browserTarget": "sitc-web-app:build:dev"
            },
            "staging": {
              "browserTarget": "sitc-web-app:build:staging"
            },
            "production": {
              "browserTarget": "sitc-web-app:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "sitc-web-app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/bundle.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/polyfills.min.js",
              "src/assets/SH-HTML-CSS-LIBRARY/js/vendors.min.js",
              "src/assets/SHUI/shui.min.js"
            ],
            "styles": [
              "src/assets/SHUI/shui-styles.css",
              "src/styles.css"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "sitc-web-app-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "sitc-web-app:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "sitc-web-app",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}

I separately added the 'local' part inside 'serve->configurations' and 'configurations' as I am running my code in local environment also.

package.json

{
  "name": "abc-web-app",
  "version": "0.0.0",
  "license": "XYZ",
  "scripts": {
    "ng": "ng",
    "start": "ng serve -o --configuration=local",
    "build-dev": "ng build --prod --configuration=dev --output-path=dist/dev",
    "build-staging": "ng build --prod --configuration=staging --output-path=dist/staging",
    "build-prod": "ng build --prod --configuration=prod --output-path=dist/prod",
    "build": "npm-run-all -p build-dev build-staging build-prod",
    "local-build-dev": "npm run build-dev && deleteAndCopy.bat dev",
    "local-build-staging": "npm run build-staging && deleteAndCopy.bat staging",
    "local-build-prod": "npm run build-prod && deleteAndCopy.bat prod",
    "local-build-all": "npm run local-build-dev && npm run local-build-staging && npm run local-build-prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.9",
    "@angular/common": "^9.1.9",
    "@angular/compiler": "^9.1.9",
    "@angular/core": "^9.1.9",
    "@angular/forms": "^9.1.9",
    "@angular/http": "^7.2.16",
    "@angular/platform-browser": "^9.1.9",
    "@angular/platform-browser-dynamic": "^9.1.9",
    "@angular/router": "^9.1.9",
    "angular2-csv": "^0.2.9",
    "auth0-js": "^9.13.2",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.6.5",
    "font-awesome": "^4.7.0",
    "jquery": "^3.5.1",
    "jquery-datetimepicker": "^2.5.21",
    "jwt-decode": "^2.2.0",
    "rxjs": "^6.5.5",
    "web-animations-js": "^2.3.2",
    "xml2js": "^0.4.23",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular/cli": "9.1.7",
    "@angular/compiler-cli": "^9.1.9",
    "@types/auth0-js": "^9.13.1",
    "@types/jasmine": "~3.5.10",
    "@types/jasminewd2": "~2.0.8",
    "@types/jquery": "^3.3.38",
    "@types/jwt-decode": "^2.2.1",
    "@types/node": "~14.0.6",
    "codelyzer": "^5.2.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.2",
    "karma": "~5.0.9",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "~3.3.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "npm-run-all": "^4.1.5",
    "protractor": "~7.0.0",
    "ts-node": "~8.10.2",
    "tslint": "~6.1.2",
    "typescript": "3.9.3",
    "@angular-devkit/build-angular": "~0.901.7"
  }
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "baseUrl": "src",
    "paths": {
      "@abc/models/*": ["app/models/*", "app/modules/booking-portal/models/*", "app/modules/training-portal/models/*"],
      "@abc/constants": ["app/constants"]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "preserveWhitespaces": false
  }
}

Kindly help. Any help towards a solution regarding this is highly appreciated.
Thanks in advance.

Body:
Solved it.
In tsconfig.app.json file looked like :-

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "sourceMap": "true",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

updated souceMap value to true instead of "true".